progs/collatz.scala
changeset 39 c6fe374a5fca
parent 37 38f3868891f0
equal deleted inserted replaced
38:2c96963b2e5c 39:c6fe374a5fca
     1 (binary file text/x-scala, hash: 0af1fdbd60b7644a76c39579c8201b481ba86641)
     1 // Part 1 about the 3n+1 conceture
       
     2 //=================================
       
     3 
       
     4 
       
     5 //(1) Complete the collatz function below. It should
       
     6 //    recursively calculate the number of steps needed 
       
     7 //    until the collatz series reaches the number 1.
       
     8 //    If needed you can use an auxilary function that
       
     9 //    performs the recursion. The function should expect
       
    10 //    arguments in the range of 1 to 1 Million.
       
    11 
       
    12 def collatz(n: Long): ... = ...
       
    13 
       
    14 
       
    15 //(2)  Complete the collatz bound function below. It should
       
    16 //     calculuate how many steps are needed for each number 
       
    17 //     from 1 upto a bound and returns the maximum number of
       
    18 //     steps and the corresponding number that needs that many 
       
    19 //     steps. You should expect bounds in the range of 1
       
    20 //     upto 1 million. The first component of the pair is
       
    21 //     the maximum number of steps and the second is the 
       
    22 //     corresponding number.
       
    23 
       
    24 def collatz_max(bnd: Int): (Int, Int) = ...
       
    25 
       
    26