i = 4; while(there exists such p and q that prime(p) and prime(q) and p+q == i)) i+=2;
keyword: Goldbach conjecture. The Goldbach conjecture states that this program will never halt. No one could prove this yet; seems to be really hard.
"Every even integer greater than 2 can be expressed as the sum of two primes."
My program is simply constructed in such a way that it terminates if and only if the Goldbach conjecture is not true. Maybe my pseudocode is not very precise (and also english is not my mother language), but given the Goldbach conjecture anyone can construct the program more precisely if needed.
int i = 4;
bool sumFound = true;
while(sumFound)
{
sumFound = false;
for(int p = 0; p < MAX_INT && !sumFound; p++)
{
if (isPrime(p))
{
for (int q = 0; q < MAX_INT && !sumFound; q++)
{
if (isPrime(q))
{
if (p + q == i)
{
i += 2;
sumFound = true;
}
}
}
}
}
}
You could use big integers, but it'd still be bound by whatever the max size is for that. This program would eventually terminate. Could you write an implementation where the limitations of the system don't get in the way of the theoretical mathematical limitation? I guess you could build some system which can accommodate arbitrarily large numbers, but even that would be limited by the computer specs.I guess what I'm saying is, isn't the implementation of the program the test in itself?
1) Assuming rand(x,y) gives a uniform distribution between x and y:
for (int a = 0; a < INT_MAX; a += rand(-1,1));
2) I can't find the source any more, but someone basically implemented a big int library with bit twiddling to allow for an upper bound on a loop that would finish after the heat-death of the universe, assuming generous CPU specs. Not infinite, but also non-terminating.3) Anything that makes a system call. You might never get scheduled again!
"The proof itself is over 100 pages long and consumed seven yearsof Wiles's research time. For solving Fermat's Last Theorem, he was knighted, and received other honors."
http://en.wikipedia.org/wiki/Wiles%27s_proof_of_Fermat%27s_L...
For giving a percentage, you need to specify a distribution of programmes first. E.g. programmes created reading from /dev/random, or programmes downloaded at random from the internet, or something more sensible.