Posts

Project Euler - Multiples of 3 and 5

Image
When I was at school this game was known as Fizz Buzz.  We'd sit in a circle and starting at 1, each person in the circle would say the next number. "One", "two" etc When it's a player's turn to say a number divisible by 3, they say, "fizz" and a number divisible by 5, they say, "buzz".  So, when you get to 15, the player says, "fizz buzz".  As a Maths nerd, this was one of my favourite games at school!   The first Project Euler challenge is a lot like Fizz Buzz.  To quote the website, it looks like this: If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23. Find the sum of all the multiples of 3 or 5 below 1000. There may be a quicker way of coding this than my method, but I like to keep things neat and this seemed like a great way to make use of C#'s IEnumerable collection.         public static IEnumerable<long> EnumerateMultiples(long ...