Browse by Tags

All Tags » C# 3.0 (RSS)

A cool way to find out whether a number is palindromic

In this blog entry I proposed a solution to Problem 4 at Project Euler , a crucial element of the problem is to find out whether a number is a palindrome (909 is, 809 isn't), a bit out of laziness and a bit in order to reuse existing methods, I decided...

Which is the ten thousand first prime?

Prime numbers have a good deal of practical applications (for example in cryptography) but let's face it, even if they would have none, they would still be the favorite toy of mathematicians . In Problem 7 of Project Euler , we are asked to find the 10001st...

The square of the sum vs. the sum of the squares

The sixth Project Euler problem poses an exercise that, to me, offers no major hurdles: What is the difference between the sum of the squares and the square of the sums [of a sequence of natural numbers]? The functional C# solution is fairly easy to write...

Recursive lambdas and sequence aggregations

The fifth problem at Project Euler proposes this nostalgic primary school exercise: find the smallest quantity that is evenly divisible by some numbers, the least common multiple of 1, 2, 3, ..., 20 to be precise. To begin with, let's remember the old...

Nested sequences and palindrome numbers

Problem 4 of Project Euler poses and impractical albeit intriguing problem: given all three digit numbers (100, 101, 102, ..., 998, 999), find the largest product of 2 of those numbers, where the product is a palindrome . For example, 580.085 is the product...

Finding the largest prime factor of a number

This is another classic problem at Project Euler that can be solved with the old trick of top down programming, like so: PrimeFactors(number).DefaultIfEmpty(number).Max(); It's a nice solution, supposing PrimeFactors() actually returns all prime factors...

Project Euler and infinite sequences in C#

The second problem at Project Euler proposes: Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 1 and 2, the first 10 terms will be: 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ... Find the sum of all the even...
Posted by Edgar Sánchez | with no comments

Project Euler and functional C#

I think I already talked (a long time ago) about Project Euler : a set of problems, mainly math oriented, keen to be solved with a computer program. To be sure, it's not particularly deep math, but the problems posed go fairly quickly from really easy...
More Posts