If I have code like this
for (long i = 0; i < Long.MAX_VALUE; i++)
{
//do something trivial
}
How long will it take theoretically for the loop to finish?
Suppose, just for argument's sake, that you've got a very fast computer that can perform about 2 billion loop iterations per second (a 2 GHz machine could just barely do that if there really isn't anything in the loop). Since Long.MAX_VALUE
is 2 billion times 4 billion, that loop will take around 4 billion seconds, or something over 120 years.
There's no point in starting that loop today. Wait until computers get faster, and then it will be done sooner.
I believe the answer you are looking for is: It will not finish in your lifetime.
Edit: I should qualify that--On existing hardware or any hardware I can conceive of; perhaps when quantum computing becomes popular you will have to re-evaluate this question.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With