progs/collatz.scala
author Christian Urban <christian dot urban at kcl dot ac dot uk>
Wed, 14 Sep 2016 16:51:04 +0100
changeset 419 4110ab35e5d8
parent 407 4b454a6d1814
permissions -rw-r--r--
updated courseworks

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