Project Euler

All posts tagged Project Euler

I probably won't do any more of these, and I hadn't really planned on even doing this one, but I've been inspired. Apparently some Russians found my first post about doing Project Euler problems in LaTeX. According to google translate, my post was described as being part of "the horrors of our Internet" that our comrade stumbled on inadvertently through searching for something completely unrelated. Read more >>
I've been joking for a while now that I was going to start solving project euler problems in LaTeX.  Then today I finally did one.  So let's talk about solving Project Euler problem number 1 (the easy one) using only LaTeX. The problem asks you to sum up all the positive integers below 1000 which are divisible by 3 or 5 (or both).  Doing this in R is easy.  You could efficiently do which Read more >>
Problem:  What is the greatest product of four adjacent numbers in any direction (up,  down,  left, right,  or diagonally) in the 20×20 grid? Commentary:  Well, it's been a while since I've posted anything.  Once again, the semester and research get the better of me.  As for this problem, like several before it I will be passing off some things to the shell for convenience.  This can Read more >>
Problem: Find the sum of all the primes below two million. Commentary: If you're not careful, this problem can really get you in R. In poking around the internet, there are a few solutions to this problem, but all the ones I've tested are slow. Some, even from people who are better at R than me, are VERY slow. That linked one in particular took 6 minutes and 8.728000 seconds to complete. My Read more >>
Problem: There exists exactly one Pythagorean triplet for which a + b + c = 1000. Find the product abc. Commentary: I'm not proud of this solution. Every time I would look at this solution, I just knew there was something really obvious I was missing--that I was doing this in the most bone-headed way possible. So then I finally just gave up and checked the writeup at Project Euler, and yep, Read more >>
Problem: Find the greatest product of five consecutive digits in the 1000-digit number. Commentary: So this solution is probably a little non-standard. I've actually got a huge blog post coming up about the little "trick" I use here, so I won't go into it at length just yet. But before we go into the "trick", I want to explain why it is that I'm doing the weird crap that I'm doing--afterwards Read more >>
Problem: What is the 10001st prime number? Commentary: So it's finally time to discuss my prime-searching algorithm, as promised back in Problem 5. We will find primes in the following way: 2 and 3 are prime We examine the odd integers (having already discovered the only even prime) starting with $latex i=5$. First, check if $latex i$ is of the form $latex 6k+3$ for some integer $latex Read more >>
Problem: Find the difference between the sum of the squares of the first one hundred natural numbers and the square of the sum. Commentary: I taught a variety of freshman math courses at my university for roughly 5 years. As such, this problem is very near and dear to my heart. I can't tell you how many kids show up at university thinking they're hot shits because they took Calc 1 in high Read more >>