progs/collatz2.scala
changeset 409 fb8ee3f58d19
equal deleted inserted replaced
408:5322e1c46890 409:fb8ee3f58d19
       
     1 def collatz(n: BigInt) : Boolean = n match {
       
     2   case n if (n == 1) => true
       
     3   case n if (n % 2 == 0) => collatz(n / 2)  
       
     4   case _ => collatz(3 * n + 1)
       
     5 }