progs/collatz.scala
changeset 18 87e55eb309ed
parent 15 52713e632ac0
child 24 66b97f9a40f8
equal deleted inserted replaced
17:ecf83084e41d 18:87e55eb309ed
     7 //    until the collatz series reaches the number 1.
     7 //    until the collatz series reaches the number 1.
     8 //    If needed you can use an auxilary function that
     8 //    If needed you can use an auxilary function that
     9 //    performs the recursion. The function should expect
     9 //    performs the recursion. The function should expect
    10 //    arguments in the range of 1 to 10 Million.
    10 //    arguments in the range of 1 to 10 Million.
    11 
    11 
    12 def collatz(n: Long): Int = ...
    12 def collatz(n: Long): ... = ...
    13 
    13 
    14 
    14 
    15 //(2)  Complete the collatz bound function below. It should
    15 //(2)  Complete the collatz bound function below. It should
    16 //     calculuate how many steps are needed for each number 
    16 //     calculuate how many steps are needed for each number 
    17 //     from 1 upto a bound and return the maximum number of
    17 //     from 1 upto a bound and returns the maximum number of
       
    18 //     steps and the corresponding number that needs that many 
    18 //     steps. You should expect bounds in the range of 1
    19 //     steps. You should expect bounds in the range of 1
    19 //     upto 10 million. 
    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.
    20 
    23 
    21 def collatz_max(bnd: Int): Int = ...
    24 def collatz_max(bnd: Int): (Int, Int) = ...
    22 
    25 
    23 
    26