Created
October 11, 2012 09:23
-
-
Save rkotov93/3871220 to your computer and use it in GitHub Desktop.
factorial
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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