Skip to content

Instantly share code, notes, and snippets.

@LeoAdamek
Created November 9, 2012 19:09
Show Gist options
  • Select an option

  • Save LeoAdamek/4047592 to your computer and use it in GitHub Desktop.

Select an option

Save LeoAdamek/4047592 to your computer and use it in GitHub Desktop.
Factorial Operator
object f {
def f(x: BigInt):BigInt = if(x < 2) 1 else x * f(x-1)
implicit def factorial_operator(x: BigInt) = new { def ! = f(x) }
def main(args: Array[String]){
args.foreach {
i => {
println(i + "! = " + (BigInt.apply(i)!) )
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment