diff --git a/Factorial.scala b/Factorial.scala index 65e5bc2..a987e9e 100644 --- a/Factorial.scala +++ b/Factorial.scala @@ -1,7 +1,7 @@ import scala.math.BigInt object Factorial extends App { - def factorial(i: BigInt): BigInt = if (i == 0) 1 else i * factorial(i - 1) + def factorial(i: BigInt,acc: BigInt): BigInt = if (i == 0) acc else factorial(i - 1, i*acc) - println(factorial(10000)) + println(factorial(10000,1)) }