# HG changeset patch # User Christian Urban <christian dot urban at kcl dot ac dot uk> # Date 1471736344 -3600 # Node ID fb8ee3f58d1985393e94e7a9fb7b1bdfcbdece9a # Parent 5322e1c46890eb608df254bee95048ee9014b628 added diff -r 5322e1c46890 -r fb8ee3f58d19 progs/collatz2.scala --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/progs/collatz2.scala Sun Aug 21 00:39:04 2016 +0100 @@ -0,0 +1,5 @@ +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) +}