Samuel Jack has been tackling Project Euler over on his blog http://blog.functionalfun.net. This is the source code to the solutions. The idea is to solve the problem with C#3.0 using a functional programming style as far as possible. So you'll find practical examples of Iterators, lambda expressions, C# Query Syntax, Recursion, and even a spot of Trampolining! Problems Solved:(Links go to the explanation of each solution)
| Problem 1 | Add all the natural numbers below one thousand that are multiples of 3 or 5. | LINQ basics |
| Problem 2 | Find the sum of all the even-valued terms in the Fibonacci sequence which do not exceed four million. | Iterators |
| Problem 3 | Find the largest prime factor of a composite number. | Recursion |
| Problem 4 | Find the largest palindrome made from the product of two 3-digit numbers. | C# query syntax |
| Problem 5 | What is the smallest number divisible by each of the numbers 1 to 20? | Aggregate method |
| Problem 6 | What is the difference between the sum of the squares and the square of the sums? | |
| Problem 7 | Find the 10001st prime. | Unfold |
| Problem 8 | Discover the largest product of five consecutive digits in the 1000-digit number. | Lazy Trampoline |
| Problem 9 | Find the only Pythagorean triplet, {a, b, c}, for which a + b + c = 1000. | Anonymous types, multiple from clauses |
| Problem 10 | Calculate the sum of all the primes below two million. | |
| Problem 11 | What is the greatest product of four numbers on the same straight line in the 20 by 20 grid? | Concat method |
| Problem 12 | What is the value of the first triangle number to have over five hundred divisors? | Lazy Aggregation, Concat method |
| Problem 13 | Find the first ten digits of the sum of one-hundred 50-digit numbers. | Zip method |
| Problem 14 | Find the longest sequence using a starting number under one million. | Recursive lambda functions, Memoization |
| Problem 15 | Starting in the top left corner in a 20 by 20 grid, how many routes are there to the bottom right corner? | Unfold |
| Problem 16 | What is the sum of the digits of the number 2^1000? | Unfold, Zip, Handling large integers |
| Problem 17 | How many letters would be needed to write all the numbers in words from 1 to 1000? | Recursion |
| Problem 59 | Using a brute force attack, can you decrypt the cipher using XOR encryption? | |
| Problem 89 | Develop a method to express Roman numerals in minimal form. | Aggregate, Lazy Trampolining |
|