templates/collatz.scala
changeset 129 1b0f1573c27c
parent 127 01d522ba48d4
child 135 e59aebee9770
equal deleted inserted replaced
128:fd03a2f06286 129:1b0f1573c27c
     8 //    until the collatz series reaches the number 1.
     8 //    until the collatz series reaches the number 1.
     9 //    If needed, you can use an auxiliary function that
     9 //    If needed, you can use an auxiliary function that
    10 //    performs the recursion. The function should expect
    10 //    performs the recursion. The function should expect
    11 //    arguments in the range of 1 to 1 Million.
    11 //    arguments in the range of 1 to 1 Million.
    12 
    12 
    13 //def collatz(n: Long): ... = ...
    13 //def collatz(n: Long) : Long = ...
    14 
    14 
    15 
    15 
    16 //(2)  Complete the collatz bound function below. It should
    16 //(2)  Complete the collatz bound function below. It should
    17 //     calculate how many steps are needed for each number 
    17 //     calculate how many steps are needed for each number 
    18 //     from 1 up to a bound and then calculate the maximum number of
    18 //     from 1 up to a bound and then calculate the maximum number of
    20 //     steps. Again, you should expect bounds in the range of 1
    20 //     steps. Again, you should expect bounds in the range of 1
    21 //     up to 1 Million. The first component of the pair is
    21 //     up to 1 Million. The first component of the pair is
    22 //     the maximum number of steps and the second is the 
    22 //     the maximum number of steps and the second is the 
    23 //     corresponding number.
    23 //     corresponding number.
    24 
    24 
    25 //def collatz_max(bnd: Long): (Long, Long) = ...
    25 //def collatz_max(bnd: Long) : (Long, Long) = ...
    26 
    26 
    27 
    27 
    28 }
    28 }