[algogeeks] Re: Run for a google years
@Aamir: No, it won't overflow. The maximum double is approximately 10^307.95. His value is well within the range of doubles. The problem is that doubles don't have enough precision. See my preceding post for an explanation. Dave On May 13, 6:42 am, Aamir Khan wrote: > double n will overflow... > > On 5/13/11, bittu wrote: > > > > > > > @Dave... I think 1 Googol Year is =10^100 not 10^116.5 ?? why u have > > used > > > so then we have to write the single line program that googol years of > > time ?? & we have processor that can execute the instruction in 10^9 > > per second so the time required by googol year in second > > which is equals to time t=pow(10,109)*365*86400 sec. > > > so program is like > > > #include > > #include > > > int main() { > > > double n = pow(10, 109) * 365 * 86400; > > > while(n--); > > } > > > Correct me if anything wrong??? > > > Thanks & Regards > > Shashank Mani>>"The Best Way To Escape From The problem is Solve It" > > Computer Science & Engg. > > BIT Mesra > > > -- > > You received this message because you are subscribed to the Google Groups > > "Algorithm Geeks" group. > > To post to this group, send email to algogeeks@googlegroups.com. > > To unsubscribe from this group, send email to > > algogeeks+unsubscr...@googlegroups.com. > > For more options, visit this group at > >http://groups.google.com/group/algogeeks?hl=en. > > -- > Aamir Khan > Indian Institute of Technology Roorkee, > Roorkee, Uttarakhand, > India , 247667 > Phone: +91 9557647357 > email: aami...@iitr.ernet.in > ak4u2...@gmail.com- Hide quoted text - > > - Show quoted text - -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] Re: Run for a google years
@Bittu: I wrote that a google years ~= 10^116.5 nanoseconds. If you take the base-10 logarithm of your time t, you will get about 116.5. Regarding your code, the dynamic range of doubles exceeds 10^116.5, so you can calculate n. However, since n is approximately 2^387, but only the high-order 52 bits is stored, it follows that 1 is insignificant to n; therefore, subtracting 1 (n--) does not change the numerical value of n. Your code will run forever. Dave On May 13, 4:57 am, bittu wrote: > @Dave... I think 1 Googol Year is =10^100 not 10^116.5 ?? why u have > used > > so then we have to write the single line program that googol years of > time ?? & we have processor that can execute the instruction in 10^9 > per second so the time required by googol year in second > which is equals to time t=pow(10,109)*365*86400 sec. > > so program is like > > #include > #include > > int main() { > > double n = pow(10, 109) * 365 * 86400; > > while(n--); > > } > > Correct me if anything wrong??? > > Thanks & Regards > Shashank Mani>>"The Best Way To Escape From The problem is Solve It" > Computer Science & Engg. > BIT Mesra -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Re: Run for a google years
And yes corrct me if i am wrong in the assertion that the code wont work On Fri, May 13, 2011 at 7:24 PM, saurabh singh wrote: > No Amir,it wont.We will not be able to store each and every digit in the > double though > Check out ieee floating point standard,that will clarify it. > But yes in the context of above problem the code wont work i think due to > precision problem... > > > On Fri, May 13, 2011 at 5:12 PM, Aamir Khan wrote: > >> double n will overflow... >> >> On 5/13/11, bittu wrote: >> > @Dave... I think 1 Googol Year is =10^100 not 10^116.5 ?? why u have >> > used >> > >> > so then we have to write the single line program that googol years of >> > time ?? & we have processor that can execute the instruction in 10^9 >> > per second so the time required by googol year in second >> > which is equals to time t=pow(10,109)*365*86400 sec. >> > >> > so program is like >> > >> > #include >> > #include >> > >> > int main() { >> > >> > double n = pow(10, 109) * 365 * 86400; >> > >> > while(n--); >> > } >> > >> > Correct me if anything wrong??? >> > >> > Thanks & Regards >> > Shashank Mani>>"The Best Way To Escape From The problem is Solve It" >> > Computer Science & Engg. >> > BIT Mesra >> > >> > -- >> > You received this message because you are subscribed to the Google >> Groups >> > "Algorithm Geeks" group. >> > To post to this group, send email to algogeeks@googlegroups.com. >> > To unsubscribe from this group, send email to >> > algogeeks+unsubscr...@googlegroups.com. >> > For more options, visit this group at >> > http://groups.google.com/group/algogeeks?hl=en. >> > >> > >> >> >> -- >> Aamir Khan >> Indian Institute of Technology Roorkee, >> Roorkee, Uttarakhand, >> India , 247667 >> Phone: +91 9557647357 >> email: aami...@iitr.ernet.in >>ak4u2...@gmail.com >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Algorithm Geeks" group. >> To post to this group, send email to algogeeks@googlegroups.com. >> To unsubscribe from this group, send email to >> algogeeks+unsubscr...@googlegroups.com. >> For more options, visit this group at >> http://groups.google.com/group/algogeeks?hl=en. >> >> > > > -- > Saurabh Singh > B.Tech (Computer Science) > MNNIT ALLAHABAD > > > -- Saurabh Singh B.Tech (Computer Science) MNNIT ALLAHABAD -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Re: Run for a google years
No Amir,it wont.We will not be able to store each and every digit in the double though Check out ieee floating point standard,that will clarify it. But yes in the context of above problem the code wont work i think due to precision problem... On Fri, May 13, 2011 at 5:12 PM, Aamir Khan wrote: > double n will overflow... > > On 5/13/11, bittu wrote: > > @Dave... I think 1 Googol Year is =10^100 not 10^116.5 ?? why u have > > used > > > > so then we have to write the single line program that googol years of > > time ?? & we have processor that can execute the instruction in 10^9 > > per second so the time required by googol year in second > > which is equals to time t=pow(10,109)*365*86400 sec. > > > > so program is like > > > > #include > > #include > > > > int main() { > > > > double n = pow(10, 109) * 365 * 86400; > > > > while(n--); > > } > > > > Correct me if anything wrong??? > > > > Thanks & Regards > > Shashank Mani>>"The Best Way To Escape From The problem is Solve It" > > Computer Science & Engg. > > BIT Mesra > > > > -- > > You received this message because you are subscribed to the Google Groups > > "Algorithm Geeks" group. > > To post to this group, send email to algogeeks@googlegroups.com. > > To unsubscribe from this group, send email to > > algogeeks+unsubscr...@googlegroups.com. > > For more options, visit this group at > > http://groups.google.com/group/algogeeks?hl=en. > > > > > > > -- > Aamir Khan > Indian Institute of Technology Roorkee, > Roorkee, Uttarakhand, > India , 247667 > Phone: +91 9557647357 > email: aami...@iitr.ernet.in >ak4u2...@gmail.com > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To post to this group, send email to algogeeks@googlegroups.com. > To unsubscribe from this group, send email to > algogeeks+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/algogeeks?hl=en. > > -- Saurabh Singh B.Tech (Computer Science) MNNIT ALLAHABAD -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Re: Run for a google years
double n will overflow... On 5/13/11, bittu wrote: > @Dave... I think 1 Googol Year is =10^100 not 10^116.5 ?? why u have > used > > so then we have to write the single line program that googol years of > time ?? & we have processor that can execute the instruction in 10^9 > per second so the time required by googol year in second > which is equals to time t=pow(10,109)*365*86400 sec. > > so program is like > > #include > #include > > int main() { > > double n = pow(10, 109) * 365 * 86400; > > while(n--); > } > > Correct me if anything wrong??? > > Thanks & Regards > Shashank Mani>>"The Best Way To Escape From The problem is Solve It" > Computer Science & Engg. > BIT Mesra > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To post to this group, send email to algogeeks@googlegroups.com. > To unsubscribe from this group, send email to > algogeeks+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/algogeeks?hl=en. > > -- Aamir Khan Indian Institute of Technology Roorkee, Roorkee, Uttarakhand, India , 247667 Phone: +91 9557647357 email: aami...@iitr.ernet.in ak4u2...@gmail.com -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] Re: Run for a google years
@Dave... I think 1 Googol Year is =10^100 not 10^116.5 ?? why u have used so then we have to write the single line program that googol years of time ?? & we have processor that can execute the instruction in 10^9 per second so the time required by googol year in second which is equals to time t=pow(10,109)*365*86400 sec. so program is like #include #include int main() { double n = pow(10, 109) * 365 * 86400; while(n--); } Correct me if anything wrong??? Thanks & Regards Shashank Mani>>"The Best Way To Escape From The problem is Solve It" Computer Science & Engg. BIT Mesra -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] Re: Run for a google years
I don't know that it takes exactly 9 operations. I ran the program on my 3 GHz computer with n=4. It took 17 seconds. 17*3 billion / 2^32 is 11.87 clock cycles per iteration through the loop. A clock cycle is not the same as an operation, because many machine operations take more than one clock cycle. If the computer we are using for this problem can run one iteration of the loop as a single operation, n=49 would be enough. If it takes 9 operations, n=48 would be enough. So it depends on the computer, and I don't really have enough information to say which value of n to use. However, n=49 certainly meets the requirements of the problem, even if it is excessive. Don On May 11, 7:11 am, Aamir Khan wrote: > On Mon, May 9, 2011 at 8:31 PM, Don wrote: > > That would do it if you have a 64-bit type, which most implementations > > have, but the standard does not require. > > I think that I can make it shorter and cleaner. > > > int main(int argc, char* argv[]) > > { > > const int n=49; > > char a[n]={0}; > > int p=0; > > > // This line will run for 10^100 years > > for(; p < n; p = ++a[p] ? 0 : p + 1); > > > return 0; > > } > > > The array of 49 bytes provides 392 bits of state, which will take more > > than the 2^387 cycles available in a google years. > > > If the processor takes 9 operations to execute the loop, a value of > > n=48 would be sufficient. > > Can you elaborate the 9 operations that execution of for loop will take. > > Don > > > > > > > On May 7, 12:24 pm, Dave wrote: > > > @Don: Here is my solution: > > > > unsigned long long int a=1; > > > unsigned long long int b=0; > > > unsigned long long int c=0; > > > unsigned long long int d=0; > > > unsigned long long int e=0; > > > unsigned long long int f=0; > > > unsigned long long int g=0; > > > unsigned long long int h=0; > > > /* here is the line "/ > > > while(a)if(!++h)if(!++g)if(!++f)if(!++e)if(!++d)if(!++c)if(!++b)++a; > > > > My reasoning is as follows: 1 google years ~= 10^116.5 nanoseconds ~= > > > 2^387. Thus, incrementing an integer of length 387 bits once every > > > nanosecond should take a google years to overflow. Seven 64-bit > > > integers provides 448 bits of state. > > > > Dave > > > > On May 6, 11:25 am, Don wrote: > > > > > What is the shortest single line in a C program which will take more > > > > than a google years to execute, but will eventually complete? You are > > > > permitted to have code before or after the line, but execution of the > > > > code must remain on that line, meaning no function calls, etc. Assume > > > > a processor which executes 1 billion operations a second. > > > -- > > You received this message because you are subscribed to the Google Groups > > "Algorithm Geeks" group. > > To post to this group, send email to algogeeks@googlegroups.com. > > To unsubscribe from this group, send email to > > algogeeks+unsubscr...@googlegroups.com. > > For more options, visit this group at > >http://groups.google.com/group/algogeeks?hl=en. > > -- > Aamir Khan > Indian Institute of Technology Roorkee, > Roorkee, Uttarakhand, > India , 247667 > Phone: +91 9557647357 > email: aami...@iitr.ernet.in > ak4u2...@gmail.com -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Re: Run for a google years
On Mon, May 9, 2011 at 8:31 PM, Don wrote: > That would do it if you have a 64-bit type, which most implementations > have, but the standard does not require. > I think that I can make it shorter and cleaner. > > int main(int argc, char* argv[]) > { >const int n=49; >char a[n]={0}; >int p=0; > >// This line will run for 10^100 years >for(; p < n; p = ++a[p] ? 0 : p + 1); > >return 0; > } > > The array of 49 bytes provides 392 bits of state, which will take more > than the 2^387 cycles available in a google years. > > If the processor takes 9 operations to execute the loop, a value of > n=48 would be sufficient. > > Can you elaborate the 9 operations that execution of for loop will take. Don > > On May 7, 12:24 pm, Dave wrote: > > @Don: Here is my solution: > > > > unsigned long long int a=1; > > unsigned long long int b=0; > > unsigned long long int c=0; > > unsigned long long int d=0; > > unsigned long long int e=0; > > unsigned long long int f=0; > > unsigned long long int g=0; > > unsigned long long int h=0; > > /* here is the line "/ > > while(a)if(!++h)if(!++g)if(!++f)if(!++e)if(!++d)if(!++c)if(!++b)++a; > > > > My reasoning is as follows: 1 google years ~= 10^116.5 nanoseconds ~= > > 2^387. Thus, incrementing an integer of length 387 bits once every > > nanosecond should take a google years to overflow. Seven 64-bit > > integers provides 448 bits of state. > > > > Dave > > > > On May 6, 11:25 am, Don wrote: > > > > > What is the shortest single line in a C program which will take more > > > than a google years to execute, but will eventually complete? You are > > > permitted to have code before or after the line, but execution of the > > > code must remain on that line, meaning no function calls, etc. Assume > > > a processor which executes 1 billion operations a second. > > > > > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To post to this group, send email to algogeeks@googlegroups.com. > To unsubscribe from this group, send email to > algogeeks+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/algogeeks?hl=en. > > -- Aamir Khan Indian Institute of Technology Roorkee, Roorkee, Uttarakhand, India , 247667 Phone: +91 9557647357 email: aami...@iitr.ernet.in ak4u2...@gmail.com -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] Re: Run for a google years
@Aamir: First, regarding overflow, 1000 = -128. Thus, the cycle is 0, 1, 2, ..., 127, -128, -127, ..., -1, and back to 0. Second, regarding your assertion that you only need a single character instead of an array of them: Based on the above sequence, every time a[0] cycles back to 0, p is set to 1. The next step increments a[1]. If that doesn't result in 0, then p is reset to 0, but if it does result in 0, then p is set to 2, and a[2] will be incremented. This means that a[0] has reached 0 256 times, so a[0] has been incremented 256^2 = 65,536 times. After a[0] has been incremented 256^3 times, p will be set to 3. Etc. After a[0] has been incremented 256^49 times, p will be set to 49 and the loop will be terminated. But 256^49 = 2^392. But 2^392 nanoseconds exceeds 1 google years. Dave On May 10, 4:59 pm, Aamir Khan wrote: > On Mon, May 9, 2011 at 8:31 PM, Don wrote: > > That would do it if you have a 64-bit type, which most implementations > > have, but the standard does not require. > > I think that I can make it shorter and cleaner. > > > int main(int argc, char* argv[]) > > { > > const int n=49; > > char a[n]={0}; > > I think we can use a single character like char a=0; instead of array of > characters as ultimately the value is incremented for a[0] only in your > code. > > And i was testing with smaller values of n=1 and found something strange > like the value of a[p] increases from 0 to 127 (thats normal) but after > adding 1 to 127 it shows -128..I know that char is of 1byte or 8 bits only > and after +127 its value will overflow. > > I have question regarding the same: > > 1) How to calculate the next value in case of overflow. As i tried > calculating by binary addition and 0111 + 1 = 1000 thats means > answer should have been -0 or 0. > > int p=0; > > > > > > > > > // This line will run for 10^100 years > > for(; p < n; p = ++a[p] ? 0 : p + 1); > > > return 0; > > } > > > The array of 49 bytes provides 392 bits of state, which will take more > > than the 2^387 cycles available in a google years. > > > If the processor takes 9 operations to execute the loop, a value of > > n=48 would be sufficient. > > Don > > > On May 7, 12:24 pm, Dave wrote: > > > @Don: Here is my solution: > > > > unsigned long long int a=1; > > > unsigned long long int b=0; > > > unsigned long long int c=0; > > > unsigned long long int d=0; > > > unsigned long long int e=0; > > > unsigned long long int f=0; > > > unsigned long long int g=0; > > > unsigned long long int h=0; > > > /* here is the line "/ > > > while(a)if(!++h)if(!++g)if(!++f)if(!++e)if(!++d)if(!++c)if(!++b)++a; > > > > My reasoning is as follows: 1 google years ~= 10^116.5 nanoseconds ~= > > > 2^387. Thus, incrementing an integer of length 387 bits once every > > > nanosecond should take a google years to overflow. Seven 64-bit > > > integers provides 448 bits of state. > > > > Dave > > > > On May 6, 11:25 am, Don wrote: > > > > > What is the shortest single line in a C program which will take more > > > > than a google years to execute, but will eventually complete? You are > > > > permitted to have code before or after the line, but execution of the > > > > code must remain on that line, meaning no function calls, etc. Assume > > > > a processor which executes 1 billion operations a second. > > > -- > > You received this message because you are subscribed to the Google Groups > > "Algorithm Geeks" group. > > To post to this group, send email to algogeeks@googlegroups.com. > > To unsubscribe from this group, send email to > > algogeeks+unsubscr...@googlegroups.com. > > For more options, visit this group at > >http://groups.google.com/group/algogeeks?hl=en. > > -- > Aamir Khan > Indian Institute of Technology Roorkee, > Roorkee, Uttarakhand, > India , 247667 > Phone: +91 9557647357 > email: aami...@iitr.ernet.in > ak4u2...@gmail.com- Hide quoted text - > > - Show quoted text - -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Re: Run for a google years
On Mon, May 9, 2011 at 8:31 PM, Don wrote: > That would do it if you have a 64-bit type, which most implementations > have, but the standard does not require. > I think that I can make it shorter and cleaner. > > int main(int argc, char* argv[]) > { >const int n=49; >char a[n]={0}; > I think we can use a single character like char a=0; instead of array of characters as ultimately the value is incremented for a[0] only in your code. And i was testing with smaller values of n=1 and found something strange like the value of a[p] increases from 0 to 127 (thats normal) but after adding 1 to 127 it shows -128..I know that char is of 1byte or 8 bits only and after +127 its value will overflow. I have question regarding the same: 1) How to calculate the next value in case of overflow. As i tried calculating by binary addition and 0111 + 1 = 1000 thats means answer should have been -0 or 0. int p=0; > >// This line will run for 10^100 years >for(; p < n; p = ++a[p] ? 0 : p + 1); > >return 0; > } > > The array of 49 bytes provides 392 bits of state, which will take more > than the 2^387 cycles available in a google years. > > If the processor takes 9 operations to execute the loop, a value of > n=48 would be sufficient. > Don > > On May 7, 12:24 pm, Dave wrote: > > @Don: Here is my solution: > > > > unsigned long long int a=1; > > unsigned long long int b=0; > > unsigned long long int c=0; > > unsigned long long int d=0; > > unsigned long long int e=0; > > unsigned long long int f=0; > > unsigned long long int g=0; > > unsigned long long int h=0; > > /* here is the line "/ > > while(a)if(!++h)if(!++g)if(!++f)if(!++e)if(!++d)if(!++c)if(!++b)++a; > > > > My reasoning is as follows: 1 google years ~= 10^116.5 nanoseconds ~= > > 2^387. Thus, incrementing an integer of length 387 bits once every > > nanosecond should take a google years to overflow. Seven 64-bit > > integers provides 448 bits of state. > > > > Dave > > > > On May 6, 11:25 am, Don wrote: > > > > > What is the shortest single line in a C program which will take more > > > than a google years to execute, but will eventually complete? You are > > > permitted to have code before or after the line, but execution of the > > > code must remain on that line, meaning no function calls, etc. Assume > > > a processor which executes 1 billion operations a second. > > > > > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To post to this group, send email to algogeeks@googlegroups.com. > To unsubscribe from this group, send email to > algogeeks+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/algogeeks?hl=en. > > -- Aamir Khan Indian Institute of Technology Roorkee, Roorkee, Uttarakhand, India , 247667 Phone: +91 9557647357 email: aami...@iitr.ernet.in ak4u2...@gmail.com -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] Re: Run for a google years
That would do it if you have a 64-bit type, which most implementations have, but the standard does not require. I think that I can make it shorter and cleaner. int main(int argc, char* argv[]) { const int n=49; char a[n]={0}; int p=0; // This line will run for 10^100 years for(; p < n; p = ++a[p] ? 0 : p + 1); return 0; } The array of 49 bytes provides 392 bits of state, which will take more than the 2^387 cycles available in a google years. If the processor takes 9 operations to execute the loop, a value of n=48 would be sufficient. Don On May 7, 12:24 pm, Dave wrote: > @Don: Here is my solution: > > unsigned long long int a=1; > unsigned long long int b=0; > unsigned long long int c=0; > unsigned long long int d=0; > unsigned long long int e=0; > unsigned long long int f=0; > unsigned long long int g=0; > unsigned long long int h=0; > /* here is the line "/ > while(a)if(!++h)if(!++g)if(!++f)if(!++e)if(!++d)if(!++c)if(!++b)++a; > > My reasoning is as follows: 1 google years ~= 10^116.5 nanoseconds ~= > 2^387. Thus, incrementing an integer of length 387 bits once every > nanosecond should take a google years to overflow. Seven 64-bit > integers provides 448 bits of state. > > Dave > > On May 6, 11:25 am, Don wrote: > > > What is the shortest single line in a C program which will take more > > than a google years to execute, but will eventually complete? You are > > permitted to have code before or after the line, but execution of the > > code must remain on that line, meaning no function calls, etc. Assume > > a processor which executes 1 billion operations a second. > > -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] Re: Run for a google years
@Don: Here is my solution: unsigned long long int a=1; unsigned long long int b=0; unsigned long long int c=0; unsigned long long int d=0; unsigned long long int e=0; unsigned long long int f=0; unsigned long long int g=0; unsigned long long int h=0; /* here is the line "/ while(a)if(!++h)if(!++g)if(!++f)if(!++e)if(!++d)if(!++c)if(!++b)++a; My reasoning is as follows: 1 google years ~= 10^116.5 nanoseconds ~= 2^387. Thus, incrementing an integer of length 387 bits once every nanosecond should take a google years to overflow. Seven 64-bit integers provides 448 bits of state. Dave On May 6, 11:25 am, Don wrote: > What is the shortest single line in a C program which will take more > than a google years to execute, but will eventually complete? You are > permitted to have code before or after the line, but execution of the > code must remain on that line, meaning no function calls, etc. Assume > a processor which executes 1 billion operations a second. -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.