Pastebin launched a little side project called HostCabi.net, check it out ;-)Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Dec 16th, 2012  |  syntax: Java  |  size: 0.50 KB  |  hits: 27  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  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. }