PE036


Project Euler Problem #36

 

Once I solved this problem, I was reading through the forum and realized that everyone was on crack when they were solving this.  People were converting the number into a string and converting the string.  String operations are painfully slow!!!

 

How I reversed the numbers was by pulling the first digit and putting it on a new number, then multiply the new number by 10 and divide the old, then move the next digit over, etc.  I did the same thing for binary, just with two.  This is all done in the functions rev10() and rev2().

 

Runtime: 0.056 seconds

PE036_c

 


Return to list of solutions