/ Published in: Python
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
#!/usr/bin/python # Project Euler - Problem 7 # Find the 10001st prime number # Primes are divisible only by themselves num = 10001 cnt = 1 x = 2 primes = [2] while cnt < num: x = x + 1 isPrime = True for i in primes: if x % i == 0: isPrime = False break if isPrime: primes.append(x) cnt = cnt + 1 print x