Advertisement
seberm

faktorial

May 16th, 2011
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.59 KB | None | 0 0
  1. /** @author Otto Sabart - Seberm
  2. */
  3.  
  4. public class faktorial {
  5.  
  6.  
  7.         public static void main(String[] argv) {
  8.  
  9.                 if (argv.length <= 0) {
  10.                         System.out.println("chybi parametr");
  11.                         System.exit(0);
  12.                 }
  13.  
  14.                 System.out.println(faktorial.faktorial(Integer.valueOf(argv[0])));
  15.         }
  16.  
  17.  
  18.         public static int faktorial (int n) {
  19.  
  20.                 int x = 1;
  21.                
  22.  
  23.                 if (n != 0)
  24.                         x = n * faktorial(n - 1);
  25.  
  26.                 return x;
  27.         }
  28. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement