Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Test {
- /**
- * @param args
- */
- public static void main(String[] args) {
- Scanner in = new Scanner(System.in);
- System.out.println("enter");
- int num = Integer.parseInt(in.nextLine());
- long sum = 1;
- for(int i = num; i != 0; i--) {
- sum *= i;
- }
- System.out.println("Result: " + sum);
- System.out.println("Method: " + method(num));
- }
- public static long method(int i) {
- if(i == 1) return i;
- return i * method(--i);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement