Skip to content

Instantly share code, notes, and snippets.

@harshavardhana
Created July 14, 2014 06:55
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 harshavardhana/f8a0db190a678cbc975f to your computer and use it in GitHub Desktop.
Save harshavardhana/f8a0db190a678cbc975f to your computer and use it in GitHub Desktop.
Tail recursive (factorial) - scala
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