Created
February 29, 2016 18:16
-
-
Save bigjason/e7b0698e1731a27a0a5e to your computer and use it in GitHub Desktop.
This file contains hidden or 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
@scala.annotation.tailrec | |
def fact(n: Int, acc: BigInt = 1): BigInt = | |
if(n < 0) throw new Exception("n must be >= 0") | |
else if (n == 0) acc | |
else fact(n - 1, acc * n) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment