From 43a16c9f03795897cae0d7e1952d8fe85cbcf4b3 Mon Sep 17 00:00:00 2001 From: naoto Date: Tue, 1 Jun 2021 00:14:35 +0900 Subject: [PATCH] =?UTF-8?q?=E6=9C=AB=E5=B0=BE=E5=86=8D=E5=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Factorial.scala | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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)) }