I'm on my way of solving euler problem 108, therefore I want to find the integer n
so that that there are 1000 combinations of: 1/i + 1/t = 1/n
(i
and t
are random numbers). My code:
int counter = 0;
for (int n = 10000; n < 200000; n++) {
for (int i = n; i < 1000000; i++) {
for (int t = i; t < 1000000; t++) {
if ((n * (i + t)) == (i * t)) {
counter++;
if (counter == 1000) {
System.out.println("Counter: " + counter);
System.out.println("N: " + n);
System.exit(0);
}
}
}
}
counter = 0;
}
However, this does not terminate. How come? I reset the counter for each round and check if it ever reaches the value 1000.