Permalink
Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
42 lines (33 sloc) 899 Bytes
# this small python program makes a textfile that prints out
# prime numbers in rows of increasing size. the size of
# each row increases with size being the next prime number
# i created this program to see if I see patterns when printing
# prime numbers this way
SIZE = 9699690
BLANK = " "
B = 5
#First, read in the primes
p = []
f = open("p%d.txt" %SIZE) #this file is generated by sieve.py
for line in f:
p.append(int(line))
#Next, print out primes rows
cc = 0 # column count
lc = 0 # line count
outfile = open('pt%d.txt' %SIZE, 'w')
for i in range(2,SIZE):
if i in p:
# print repr(i).rjust(B),
outfile.write(repr(i).rjust(B))
else:
# print BLANK,
outfile.write(BLANK)
cc += 1
if cc == p[lc]:
lc += 1
cc = 0
#print
outfile.write('\n')
else:
pass
outfile.close()