by ssmith via Steve Smith's Blog on 9/6/2009 3:53:00 AM
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.
Original Post: Euler 7 Trivial with LINQ and Generators
The content of the postings is owned by the respective author. CSharpFeeds is not responsible for the contents of the postings. This site is automatically generated and cannot be reviewed for abusive content. If you find abusive content on CSharpFeeds, please contact us. Designated trademarks and brands are the property of their respective owners. All rights reserved.