Skip to content

Instantly share code, notes, and snippets.

@romanman
Last active August 29, 2015 14:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save romanman/08ad1da6baeb5c37e631 to your computer and use it in GitHub Desktop.
Save romanman/08ad1da6baeb5c37e631 to your computer and use it in GitHub Desktop.
public class Factorial
{
public static void main(String[] args)
{ final int NUM_FACTS = 100;
for(int i = 0; i < NUM_FACTS; i++)
System.out.println( i + "! is " + factorial(i));
}
public static int factorial(int n)
{ int result = 1;
for(int i = 2; i <= n; i++)
result *= i;
return result;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment