Guest User

Untitled

a guest
Sep 21st, 2019
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.32 KB | None | 0 0
  1. public class Factorial
  2. {
  3.     public static void main(String[] args)
  4.     {   final int NUM_FACTS = 100;
  5.         for(int i = 0; i < NUM_FACTS; i++)
  6.             System.out.println( i + "! is " + factorial(i));
  7.     }
  8.    
  9.     public static int factorial(int n)
  10.     {   int result = 1;
  11.         for(int i = 2; i <= n; i++)
  12.             result *= i;
  13.         return result;
  14.     }
  15. }
Add Comment
Please, Sign In to add comment