Skip to content

Instantly share code, notes, and snippets.

@NicolasT
Created September 14, 2009 09:22
Show Gist options
  • Save NicolasT/186571 to your computer and use it in GitHub Desktop.
Save NicolasT/186571 to your computer and use it in GitHub Desktop.
def fact(x: Int): Int = fact(x, 1)
def fact(x: Int, acc: Int): Int = x match {
case 0 => acc;
case n => fact(n - 1, x * acc)
}
val facts = (0 to 10).toList.map(fact)
println("Facts: " + facts)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment