--- a/pre_testing1/collatz.scala Wed Nov 25 18:25:15 2020 +0000
+++ b/pre_testing1/collatz.scala Fri Nov 27 00:55:24 2020 +0000
@@ -6,20 +6,11 @@
object CW6a { // for purposes of generating a jar
-/*
def collatz(n: Long): Long =
if (n == 1) 0 else
if (n % 2 == 0) 1 + collatz(n / 2) else
1 + collatz(3 * n + 1)
-*/
-def aux(n: Long, acc: Long) : Long =
- if (n == 1) acc else
- if (n % 2 == 0) aux(n / 2, acc + 1) else
- aux(3 * n + 1, acc + 1)
-
-
-def collatz(n: Long): Long = aux(n, 0)
def collatz_max(bnd: Long): (Long, Long) = {
val all = for (i <- (1L to bnd)) yield (collatz(i), i)