Skip to content
Find file
Fetching contributors…
Cannot retrieve contributors at this time
47 lines (37 sloc) 1.03 KB
# 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
# this is based on but will output coordinates for
# graphing (such as in R)
SIZE = 510510
BLANK = " "
B = 5
#First, read in the primes
p = []
f = open("p%d.txt" %SIZE) #this file is generated by
for line in f:
#Next, print out primes rows
cc = 0 # column count
lc = 0 # line count
outfile = open('ptc%d.txt' %SIZE, 'w')
for i in range(2,SIZE):
if i in p:
# print repr(i).rjust(B),
outfile.write("%d,%d,%d\n" %(i, cc, lc))
# outfile.write(repr(i).rjust(B))
# print BLANK,
cc += 1
if cc == p[lc]:
lc += 1
cc = 0
Jump to Line
Something went wrong with that request. Please try again.