jack: (Default)
[personal profile] jack
http://projecteuler.net/index.php?section=problems&id=23

By mathematical analysis, it can be shown that all integers greater than 28123 can be written as the sum of two abundant numbers ... Find the sum of all the positive integers which cannot be written as the sum of two abundant numbers.

I went back to project euler. Last time I was doing this I was trying to learn Haskell (?) which was very interesting, but wasn't that efficient, either because I wasn't very familiar for the language, or because where speed is an issue it's not as efficient to abstract away the complexities of how things are calculated.

This time I was just using C++, but hoping to stretch into some of the newer features I don't regularly get to use. I've still not got very far through project euler, but it's fun to do some straight up maths/coding :)

This was quite amenable to optimising, and it's ever so satisfying to see the run time drop from small to miniscule.

http://projecteuler.net/index.php?section=problems&id=26

Find the value of d < 1000 for which the fraction 1/d has the longest repeating decimal expansion.

This one, however, didn't even need programming. The thought process went somehting like this:

* Look at the examples given of decimal expansions from 1 to 10.
* Hm.... 1/7 is long
* In fact, as long as it's possible to be
* Google "prime decimal expansion"
* Find on wikipedia what you call a prime p with a length p-1 repeating decimal expansion for 1/p
* And a list of them
* Plug in the last one before 1000 (I couldn't prove off the top of my head there wasn't a number between 93? and 1000 that had a longer decimal expansion of the recipricol, but it didn't seem likely)
* Ding!

:)

Active Recent Entries