=== Program === // copied from K: tests/diverse/collatz.simple // Program testing Collatz' conjecture up to a user-provided number. function collatz(n) { var s=0; print("Testing Collatz' conjecture for n = ",n," ... "); while (n > 1) { s = s+1; if (n == (n/2)*2) { n = n/2; } else { n = 3*n+1; } } print("Done! It took ",s," steps.\n"); } function main() { print("Testing Collatz' conjecture up to what number? "); var m = read(); for (var i=1; i<=m; ++i) { collatz(i); } print("Done. It appears to hold.\n"); } === Output === Result: null-value Output Entity: standard-out "Testing Collatz' conjecture up to what number? ","Testing Collatz' conjecture for n = ",1," ... ","Done! It took ",0," steps.\n","Testing Collatz' conjecture for n = ",2," ... ","Done! It took ",1," steps.\n","Testing Collatz' conjecture for n = ",3," ... ","Done! It took ",7," steps.\n","Testing Collatz' conjecture for n = ",4," ... ","Done! It took ",2," steps.\n","Testing Collatz' conjecture for n = ",5," ... ","Done! It took ",5," steps.\n","Done. It appears to hold.\n"