templates1/collatz.scala
changeset 343 c8fcc0e0a57f
parent 281 87b9e3e2c1a7
--- a/templates1/collatz.scala	Sat Aug 29 16:05:59 2020 +0100
+++ b/templates1/collatz.scala	Tue Oct 13 10:21:21 2020 +0100
@@ -1,5 +1,5 @@
-// Basic Part about the 3n+1 conjecture
-//======================================
+// Preliminary Part about the 3n+1 conjecture
+//============================================
 
 object CW6a {
 
@@ -10,7 +10,7 @@
 //    performs the recursion. The function should expect
 //    arguments in the range of 1 to 1 Million.
 
-//def collatz(n: Long) : Long = ...
+def collatz(n: Long) : Long = ???
 
 
 //(2) Complete the collatz_max function below. It should
@@ -22,7 +22,22 @@
 //    the maximum number of steps and the second is the 
 //    corresponding number.
 
-//def collatz_max(bnd: Long) : (Long, Long) = ...
+def collatz_max(bnd: Long) : (Long, Long) = ???
+
+//(3) Implement a function that calculates the last_odd
+//    number in a collatz series.  For this implement an
+//    is_pow_of_two function which tests whether a number 
+//    is a power of two. The function is_hard calculates 
+//    whether 3n + 1 is a power of two. Again you can
+//    assume the input ranges between 1 and 1 Million,
+//    and also assume that the input of last_odd will not 
+//    be a power of 2.
+
+def is_pow_of_two(n: Long) : Boolean = ???
+
+def is_hard(n: Long) : Boolean = ???
+
+def last_odd(n: Long) : Long = ???
 
 }