Project Euler #30: Digit Fifth Powers

This was a fun problem. The algebra below was more fun than the code though, I think. Scratchwork for finding an upper-bound:




I coded a solution in C, entirely from scratch, because I thought this problem would be a CPU-hog. It's nearly 70 lines of code and it checks through 1,000,000 in about 4seconds. Granted neither the length of the program nor the run-time is probably optimal as I'm a C novice. I won't link to the code because it's so long, but it's worth mentioning anyways because of that sweet 4 second runtime.

Anyways, I also coded the solution in Python because it's so easy to write there and incredibly it also runs pretty quick - about 8 seconds, so twice as long as my C code. But then again, it took less than 5 minutes to write the Python program whereas it took me all morning to write the C program (and most of the curse words in the English language).





Comments