Advertisement
Guest User

Untitled

a guest
Dec 16th, 2012
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.50 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Test {
  4.  
  5.     /**
  6.      * @param args
  7.      */
  8.     public static void main(String[] args) {
  9.         Scanner in = new Scanner(System.in);
  10.         System.out.println("enter");
  11.         int num = Integer.parseInt(in.nextLine());
  12.        
  13.         long sum = 1;
  14.         for(int i = num; i != 0; i--) {
  15.             sum *= i;
  16.         }
  17.         System.out.println("Result: " + sum);      
  18.         System.out.println("Method: " + method(num));
  19.     }
  20.    
  21.     public static long method(int i) {
  22.         if(i == 1) return i;
  23.         return i * method(--i);
  24.     }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement