progs/collatz2.scala
author cu
Tue, 17 Oct 2017 13:49:45 +0100
changeset 520 2849c305b12d
parent 409 fb8ee3f58d19
permissions -rw-r--r--
updated

def collatz(n: BigInt) : Boolean = n match {
  case n if (n == 1) => true
  case n if (n % 2 == 0) => collatz(n / 2)  
  case _ => collatz(3 * n + 1)
}