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!