|           |           |           |           |           |           |           |           |           |           |           |           |
| 1 | 2 | 6 | 0 | 0 | 8 | 2 | 1 | 4 | . | . | |
| 4 | 4 | 7 | 0 | 1 | 8 | 4 | 1 | 7 | . | . | |
| 9 | 6 | 8 | 0 | 0 | 8 | 6 | 2 | 10 | . | . | |
| 16 | 8 | 9 | 1 | 1 | 8 | 16 | 3 | 13 | . | . | |
| 25 | 10 | 10 | 1 | 0 | 8 | 10 | 5 | 16 | . | . | |
| 36 | 12 | 11 | 1 | 1 | 8 | 36 | 8 | 19 | . | . | |
| 49 | 14 | 12 | 1 | 0 | 8 | 14 | 13 | 22 | . | . | |
| 64 | 16 | 13 | 1 | 1 | 8 | 64 | 21 | 25 | . | . | |
| 81 | 18 | 14 | 1 | 0 | 8 | 18 | 34 | 28 | . | . | |
| . | . | . | . | . | . | . | . | . | . | . | |
| . | . | . | . | . | . | . | . | . | . | . |
DoesItHalt.java, DoesItHalt.html
// input an integer value for k
while (k > 1)
if ((k/2) * 2 == k) // is k even?
k = k / 2;
else
k = 3 * k + 1;
halt:
string halt(string p, string x);
"Halts""Does not halt"
string selfhalt(string p);
"Halts on self" or
"Does not halt on self"
halt(p, p);
void contrary();
{
TextField program = new TextField(1000);
string p, answer;
p = program.getText();
answer = selfhalt(p);
if (answer == "Halts on self"
{
while (true) // infinite loop
answer = "x";
}
else
return;
}
halt program decides it halts, it goes
into infinite loop and goes on forever.
halt program decides it doesn't halt,
it quits immediately.
halt cannot exist!