progs/collatz2.scala
author Christian Urban <christian dot urban at kcl dot ac dot uk>
Sun, 21 Aug 2016 00:39:04 +0100
changeset 409 fb8ee3f58d19
permissions -rw-r--r--
added

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)
}