All posts for the month August, 2011

So that mean old boss of mine is at it again.  This morning I came in beaming about how many people had read my post How Much of R is Written in R (thanks by the way!).  He then asks me about one little line in that post; the one about how if you looked at the contributed packages, you'd overwhelmingly see them written in R, and that this is what really matters. He asked if I had bothered to verify Read more >>
My boss sent me an email (on my day off!) asking me just how much of R is written in the R language. This is very simple if you use R and a Unix-like system. It also gives me a good excuse to defend the title of this blog. It's librestats, not projecteulerstats, afterall. So I grabbed the R-2.13.1 source package from the cran and wrote up a little script that would look at all .R, .c, and .f 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 >>
I was hoping to begin tinkering a bit with the multicore package in R beyond some extremely trivial examples. Thanks to a combination of R's dumb quirkiness (for example, being worthless on loops), my poor planning, and general bad programming, my Saturday afternoon tinkering project is ultimately worthless in fulfilling that purpose. I was really hoping to take the prime searcher I had been using 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 >>