Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void main(String[] args) {
- System.out.println("цикл " + factCycle(4));
- System.out.println("рекурсия " + factRecyrsia(4));
- }
- public static int factCycle(int n)
- {
- int result = 1;
- for(int i=1;i<=n;i++)
- {
- result *=i;
- }
- return result;
- }
- public static int factRecyrsia(int n)
- {
- int result;
- if (n == 1)
- return 1;
- result = factRecyrsia(n - 1) * n;
- return result;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement