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?
I already wrote a brute force "is this number prime?" function. One solution would be to just increase an index and test that against whether or not it's prime and then increase a counter when it is. Actually that IS the solution. The "trick" is the prime finding function. I need to make a smarter prime finder.
EDIT: Finally writing things out in this journal has payed off! I found my notes on prime finders from last February. I think the two big things were to not check even numbers and you only need to check up to the square root of the number in question: http://chrislearnsc.blogspot.com/2011/02/maybe-i-got-it.html
No comments:
Post a Comment