| author | Christian Urban <christian.urban@kcl.ac.uk> | 
| Sun, 23 Aug 2020 14:39:58 +0100 | |
| changeset 336 | cccdae0fccc7 | 
| parent 281 | 32dfd2ca577b | 
| child 343 | 51e25cc30483 | 
| permissions | -rw-r--r-- | 
| 266 | 1 | // Basic Part about the 3n+1 conjecture | 
| 2 | //====================================== | |
| 11 
417869f65585
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: diff
changeset | 3 | |
| 281 | 4 | object CW6a {
 | 
| 11 
417869f65585
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: diff
changeset | 5 | |
| 15 | 6 | //(1) Complete the collatz function below. It should | 
| 7 | // recursively calculate the number of steps needed | |
| 8 | // until the collatz series reaches the number 1. | |
| 127 | 9 | // If needed, you can use an auxiliary function that | 
| 15 | 10 | // performs the recursion. The function should expect | 
| 24 
66b97f9a40f8
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
18diff
changeset | 11 | // arguments in the range of 1 to 1 Million. | 
| 11 
417869f65585
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: diff
changeset | 12 | |
| 129 | 13 | //def collatz(n: Long) : Long = ... | 
| 11 
417869f65585
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: diff
changeset | 14 | |
| 
417869f65585
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: diff
changeset | 15 | |
| 266 | 16 | //(2) Complete the collatz_max function below. It should | 
| 17 | // calculate how many steps are needed for each number | |
| 18 | // from 1 up to a bound and then calculate the maximum number of | |
| 19 | // steps and the corresponding number that needs that many | |
| 20 | // steps. Again, you should expect bounds in the range of 1 | |
| 21 | // up to 1 Million. The first component of the pair is | |
| 22 | // the maximum number of steps and the second is the | |
| 23 | // corresponding number. | |
| 15 | 24 | |
| 129 | 25 | //def collatz_max(bnd: Long) : (Long, Long) = ... | 
| 11 
417869f65585
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: diff
changeset | 26 | |
| 281 | 27 | } | 
| 11 
417869f65585
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: diff
changeset | 28 |