The challenge is to write a fake infinite loop in any imperative programming language.
At first sight, the code should seem not to halt at all.
As a naive example:
int f(int x)
{
return f(4.0);
}
int f(double x)
{
return 0;
}
But remember
You're not allowed to use overflows:
int f(int x)
{
if(x < 0) return -1;
return f(x*x);
}
is illegal. When the number exceeds the integer limit, the function will stop. It's a good trick. But not good enough :)
The answer with the highest votes wins! Duration is 1 week.
f(0)
? (And the first example still wouldn't fool anyone with an IQ above 90 and at least two hours of programming experience). \$\endgroup\$