progs/lecture4.scala
changeset 450 61eb4f9b8d84
parent 449 d67c5f7177a6
child 455 557d18cce0f0
equal deleted inserted replaced
449:d67c5f7177a6 450:61eb4f9b8d84
   278 
   278 
   279 
   279 
   280 // Tail recursion
   280 // Tail recursion
   281 //================
   281 //================
   282 
   282 
   283 def fact(n: BigInt): BigInt = 
   283 def fact(n: Int): Int = 
   284   if (n == 0) 1 else n * fact(n - 1)
   284   if (n == 0) 1 else n * fact(n - 1)
   285 
   285 
   286 
   286 
   287 fact(10)          
   287 fact(10)          
   288 fact(1000)        
   288 fact(1000)