Created
November 9, 2012 19:09
-
-
Save LeoAdamek/4047592 to your computer and use it in GitHub Desktop.
Factorial Operator
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
| 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