progs/collatz.scala
author Christian Urban <christian.urban@kcl.ac.uk>
Sat, 04 Sep 2021 13:29:36 +0100
changeset 832 a6e9fc38ae54
parent 407 4b454a6d1814
permissions -rw-r--r--
texupdate

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