Skip to content

Instantly share code, notes, and snippets.

@ymnk
Forked from kmizu/Factorial.scala
Created August 26, 2010 16:43
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 ymnk/551736 to your computer and use it in GitHub Desktop.
Save ymnk/551736 to your computer and use it in GitHub Desktop.
object Factorial {
def fact(n: Int) = (1 to n) product
def main(args: Array[String]) = {
val n = if(args.length == 0) 1 else args(0).toInt
1 to n foreach {i => println(i + "! = " + fact(i))}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment