Skip to content

Instantly share code, notes, and snippets.

@rkotov93
Created October 11, 2012 09:23
Show Gist options
  • Save rkotov93/3871220 to your computer and use it in GitHub Desktop.
Save rkotov93/3871220 to your computer and use it in GitHub Desktop.
factorial
public class Factorial {
public static BigInteger factorial(int n) {
BigInteger t = new BigInteger("1");
if (n == 0 || n == 1) return t;
for (int i = 2; i <= n; i++)
t = t.multiply(new BigInteger(Integer.toString(i)));
return t;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment