Skip to content

Instantly share code, notes, and snippets.

@kaipakartik
Last active January 2, 2016 18:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kaipakartik/8345235 to your computer and use it in GitHub Desktop.
Save kaipakartik/8345235 to your computer and use it in GitHub Desktop.
Problem 7 Project Euler 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 10 001st prime number?
def prime(n):
primes = [2]
start = 3
while len(primes) <= n:
isPrime = True;
for prime in primes:
if start % prime == 0:
isPrime = False;
break;
if isPrime:
primes = primes + [start]
start = start + 2
print primes[n-1]
prime(6)
prime(10001)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment