- Code: Select all
`def isprime(n):`

primenum = float(n)

if primenum % 2 == 0:

return False

primeroot = int(primenum**.5)

divisor = 3

prime = True

for x in range(primeroot):

if primenum % divisor == 0:

return False

prime = False

break

divisor += 2

if prime == True:

return True

divisor = 2

prime_num_generated = long(raw_input("Starting point(prime): "))

numbers_generated = long(raw_input("Amount of prime numbers to generate: "))

endpoint = 0

loopit = True

filename = str(prime_num_generated) + "+" + str(numbers_generated) + ".txt"

tofile = open(filename, "w")

while loopit == True:

if isprime(prime_num_generated) == True:

print prime_num_generated

endpoint += 1

filenum = str(prime_num_generated) + "\n"

tofile.write(filenum)

prime_num_generated += 2

if endpoint == numbers_generated:

loopit = False

break

tofile.close

Again, it could probably be more efficient.