progs/lecture4.scala
changeset 447 0cf1b374e146
parent 446 30b8f14b2655
child 452 ee348feb4c37
equal deleted inserted replaced
446:30b8f14b2655 447:0cf1b374e146
   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)