Return to Snippet

Revision: 27072
at May 21, 2010 10:37 by chroto


Initial Code
#!/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

Initial URL

                                

Initial Description

                                

Initial Title
Project Euler - Problem 7

Initial Tags

                                

Initial Language
Python