Advertisement
gelita

factorial

Feb 13th, 2020
245
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5 0.36 KB | None | 0 0
  1.  
  2.  
  3. import java.io.*;
  4. import java.util.*;
  5.  
  6.  
  7. class Factorial {
  8.  
  9.   private static int results = 1;
  10.    
  11.   public static void main (String[] args) {
  12.     int n = 10;
  13.     multiplyInt(n);
  14.         System.out.println(results);
  15.     }
  16.  
  17.   private static final void multiplyInt(int n ){
  18.     if(n<2){
  19.       return;
  20.     }
  21.     results *= n;
  22.     multiplyInt(n-1);
  23.   }
  24.  
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement