Created
July 14, 2014 06:55
-
-
Save harshavardhana/f8a0db190a678cbc975f to your computer and use it in GitHub Desktop.
Tail recursive (factorial) - scala
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
def factorial (a: Int, b: Int): Int = if (a == 1) b else if (a == 0) 1 else factorial (a - 1, a * b) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment