| author | Christian Urban <christian.urban@kcl.ac.uk> | 
| Wed, 04 Nov 2020 17:34:52 +0000 | |
| changeset 799 | c18b991eaad2 | 
| parent 750 | 40b7efa5fbed | 
| permissions | -rw-r--r-- | 
| 748 | 1  | 
// Collatz series  | 
2  | 
//  | 
|
3  | 
// needs writing of strings and numbers; comments  | 
|
4  | 
||
5  | 
bnd := 1;  | 
|
6  | 
while bnd < 101 do {
 | 
|
7  | 
write bnd;  | 
|
8  | 
write ": ";  | 
|
9  | 
n := bnd;  | 
|
10  | 
cnt := 0;  | 
|
11  | 
||
12  | 
  while n > 1 do {
 | 
|
13  | 
write n;  | 
|
14  | 
write ",";  | 
|
15  | 
||
16  | 
if n % 2 == 0  | 
|
17  | 
then n := n / 2  | 
|
18  | 
else n := 3 * n+1;  | 
|
19  | 
||
| 750 | 20  | 
cnt := cnt + 1  | 
| 748 | 21  | 
};  | 
22  | 
||
23  | 
write " => ";  | 
|
24  | 
write cnt;  | 
|
25  | 
write "\n";  | 
|
| 750 | 26  | 
bnd := bnd + 1  | 
27  | 
}  |