TekPub Linq Challenge!

var primes = Enumerable.Range(1, n) 
    .Where(x => (x > 1 && x < 4) || 
        !Enumerable.Range(2, x/2 - 1).Any(p => x % p == 0)); 

http://www.codethinked.com/post/2010/01/08/TekPubs-Mastering-LINQ-Challenge.aspx

http://www.tekpub.com/

Edit: This is definitely a pretty lazy solution I will admit ;P

comments powered by Disqus