Browse by Tags

All Tags » LINQ (RSS)

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...

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

A better way of getting the average salary

Related to my post yesterday in which I tried to show an appealing business sample in F#, David Taylor commented that this: can't possibly be more appealing than this: var averageSalary = companyRoll.Average(e=>e.salary); David is using LINQ of course...
More Posts