Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  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. }