Project Euler (C#)

Project Euler is a series of challenging mathematical/computer programming problems that will require more than just mathematical insights to solve. Although mathematics will help you arrive at elegant and efficient methods, the use of a computer and programming skills will be required to solve most problems.

The motivation for starting Project Euler, and its continuation, is to provide a platform for the inquiring mind to delve into unfamiliar areas and learn new concepts in a fun and recreational context.

Well, I started solving some of them. And if you would like to see exactly how, then here it is: The complete source code. You have two ways of getting it:

  • You can check out a read-only version of the code using your favorite Subversion client from http://svn.geekality.net/project-euler/trunk/
  • Or if you just want to have a peek, you can browse it online in a more fancy fashion here. There you can also download a Tarball of the code if you want to.

It’s all programmed using C# and .Net Framework 3.5 and it can be opened, compiled, et cetera, using Microsoft Visual Studio 2008. A version of the free Express Edition probably also works, but I haven’t tried it.

To run my code you will need a test runner that supports NUnit. So, either compile it and use the regular NUnit test runner that comes with NUnit when you install it, or you can use the much more handy VS2008 Add-In called TestDriven.Net that I use.

Below is a list where you can see what problems I have solved so far. The ones with a link attached are also blogged about.

Problems

1 Add all the natural numbers below one thousand that are multiples of 3 or 5. Solved
2 Find the sum of all the even-valued terms in the Fibonacci sequence which do not exceed four million. Solved
3 Find the largest prime factor of a composite number. Solved
4 Find the largest palindrome made from the product of two 3-digit numbers. Solved
5 What is the smallest number divisible by each of the numbers 1 to 20? Solved
6 What is the difference between the sum of the squares and the square of the sums? Solved
7 Find the 10001st prime. Solved
8 Discover the largest product of five consecutive digits in the 1000-digit number. Solved
9 Find the only Pythagorean triplet, {a, b, c}, for which a + b + c = 1000. Solved
10 Calculate the sum of all the primes below two million. Solved
11 What is the greatest product of four numbers on the same straight line in the 20 by 20 grid? Solved
12 What is the value of the first triangle number to have over five hundred divisors? Solved
13 Find the first ten digits of the sum of one-hundred 50-digit numbers. Solved
14 Find the longest sequence using a starting number under one million. Solved
16 What is the sum of the digits of the number 2^{1000}? Solved
25 What is the first term in the Fibonacci sequence to contain 1000 digits? Solved
  • Twitter Facebook YouTube last.fm LinkedIn Google vimeo Technorati RSS feed
  • This would be meGreetings! I am Torleif Berger, 24 years old, a Seventh-Day Adventist and currently working as a software developer. Otherwise, not much to tell. Although I do juggle a bit...