5.22.2008

More Disgusting Solutions to Horrendous Problems

After over a week, I have finally come up with a solution to Project Euler #3. In which I was asked to find the largest prime factor of the number 600851475143. This was a particularly nasty little bugger that gave me all sorts of hell. It took me a while in the first place to come up with an algorithm to figure primes. I thought I was sitting pretty when I got that working, but the number they give was too big to compute with brute force, so I had to come up with a way to chop it down a bit. The solution, as you can see, is pretty messy, and I barely have a grasp on how it even works. The print out is also really quite gross, so you have to know what you're even looking for, but it works. I've got my answer. I can sleep through my nights once more.

I've also managed to plow through another problem involving Primes that I had passed over, Problem 7, which by comparison seemed pretty meager simply asking me to find the 10001st Prime. No problem. Just takes a while to compute.

No comments: