Euler 7 Trivial with LINQ and Generators
Euler problem 7 requires returning the 10001st prime number. It notes that the 6th prime number is 13 in the problem description. Having already done some work with iterators and various number generators, including a Primes generator for previous Euler problems, the base case given in the problem can be reduced to this NUnit test:
public void SixthPrimeIs13()
{
Assert.AreEqual(13, NumberGenerator.Primes().Take(6).Last());
}
Replacing the 6 with 10001 takes care of the rest. I’m really starting to dig using LINQ for this stuff.
3 Comments
Euler 7 Trivial with LINQ and Generators said
DotNetBurner - burning hot .net content
UGG Boots sale said
including a Primes generator for previous Euler problems, the base case given in the problem can be reduced to this NUnit test:
Snoring Treatment said
I have been using a Func pad for the last 6 years. Nothing comes close. I use the ArchType model with the aluminum bevel and found that to be the best (it helps to hold it's shape better). Love 'em.