01-28-2017, 04:56 AM
(01-27-2017, 06:46 PM)Doigt Wrote:(01-27-2017, 09:33 AM)Squirrel Wrote: 80 mins to do a measly 31622776 calculations???!?!I'm disappointed squirrel, I thought you would know better. Assuming the calculations go this way:
Hmm. I don't rightly know how good or bad that is anymore.
I guess that's to be expected when you use cr@ppy computers at home, and some of the more powerful ones at work?
484
That makes a total of ~ 126,491,104 actions, not counting the recording I mentioned and what I did to kill time. (You really think I waited around while it was counting? I was playing a video game.) Note: The way the program is made, 2 additional calculations are done, but aren't printed because the condition for the while loop is no longer true. Therefore, the program would actually count not to 999,999,961,946,176, but to 1,000,000,025,191,729 (since that number is higher than myvar[0], it's never printed).Code:
long long int myvar[3];
myvar[0] = 1000000000000000; // 1 quadrillion
myvar[1] = 1;
myvar[2] = 3;
while ( myvar[1] <= myvar[0] ) // will compare the values of the myvar array ~ 31,622,776 times
{
cout << myvar[1] << ", "; // will print the value of myvar[1] ~ 31,622,776 times
// ~ 63,245,552 calculations here
myvar[1] += myvar[2];
myvar[2] += 2;
}
This is also a valid equivalent, but it's slightly longer to write:
Code:
myvar[2] = 1;
...
myvar[2]++;
myvar[1] = myvar[2] * myvar[2];
But yes, you are right, the computer was overall very slow to print the final number, but mathematically and logically, you were wrong. :-P
On topic: 676
It's disrespectful to hijack a thread is all I'm saying
Bullies have personal issues.