Project Euler: Problem 7

By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that the 6th prime is 13.

What is the 10001st prime number?

Solution

This will be a very quick one thanks to the prime number generator created earlier for problem 3. All we need is actually this one line of code:

var answer = new Eratosthenes().Take(10001).Last();

And that’s it. It takes around 50 milliseconds, which is totally acceptable I would say. It can be sped up quite a bit though if we find a more efficient prime number generator. This, however, I will try to do in a later problem.

This entry was posted in Project Euler, Software Development and tagged , . Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.
  • Bookmark and Share

One Trackback

  1. By vi-kan.net » Project Euler, Problem 7 on September 25, 2009 at 11:37

    [...] can see I will have some problems keeping up with my brother on this. Well, here’s my take on Project Eulers problem no 7: By listing the first six prime [...]

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

  • Twitter Facebook YouTube last.fm LinkedIn Google vimeo Technorati RSS feed
  • This would be meGreetings! I am Torleif Berger, 24 years old, a Seventh-Day Adventist and currently working as a software developer. Otherwise, not much to tell. Although I do juggle a bit...