Big
Prize
A
similar operation to what the following code does is carried out
in Mindcell and both algorithms give the same result.
|
d=1;f=1;n=1; a=StrToFloat(Edit1->Text);
b=StrToFloat(Edit2->Text);
c=StrToFloat(Edit3->Text);
|
Data
Entry |
for (e=1;e<a;e++)
for (y=1;y<b;y++)
for (k=1;k<c;k++)
{ d=d+e ;
f=f+y ;
m=f*k-d*k;
n=n+m ;
}
|
Loops
and Operations |
Edit4->Text=FloatToStr(n); |
Result |
PRIZE |
10000$ |
Here
there are loops that may take hundreds of years to finish. That
means, to get a result, you have to wait for hundreds of years.
Let's try to calculate
approximately how long those loops can take.
Because the step count of the
loops is a x b x c, for the minimum digit number for our prize
here, that is for 12 digits, it is 100000000000 x 100000000000 x 100000000000 = 1033.
That means, there are 1033
steps in the loops. (We took 100000000000 for ease in calculation)
So, we can find the required time
for those loops to finish by multiplying the time required for each
single step with the count of total steps.
A 10 GHz microprocessor makes 10000000000
= 1010
operation per second. (We neglect that this is cycle count and for
even a very simple addition operation, lots of cycles are needed. If
we include this in our calculation, the result will be hundreds of
times higher.)
With a computer with a 10 Ghz
microprocessor, the total time those loops will take is 1033/1010
= 1023 seconds. If
we convert it into year, we get 3.17x1015 years.