num = 28
ind_count =[25,24,23,22,21,20,19,18,17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1]
count = 0
fermat = (2^(2^num))+1
# With apologies, file names are alphabetized, but output is RULE BASED as denoted
# at end.
# From right to left, hack off 10m digit parts of the number, and save them to files in decreasing order.
# Not sure why python doesn't use 25, but the intermediate files number 24, and
# decrease by one from right to left.
# Hack off LAST 10m
n = fermat%10^10000000
fermat = fermat - n
fermat = fermat / 10^10000000
o = open('f_dat_end','w')
o.write(str(n))
o.close()
# Hack off 10m digits at a time, and creatively name data files in descending order
# until less than 10m digits remain for initial portion.
while (fermat > 10^10000000):
n=fermat%10^10000000
count = count + 1
n_count = ind_count[count]
chomp = str(n_count)
nomdeplume = ('f_dat' + chomp)
o = open(nomdeplume,'w')
o.write(str(n))
o.close()
fermat = fermat - n
fermat = fermat / 10^10000000
# put the final(LEFTMOST) digits in a "first part" file.
o = open ('first_part', 'w')
o.write(str(fermat))
o.close()
print
print "done"
# To concatenate, use datafiles increasing/ascending Left to Right, starting with "first_part,"
# then f_dat low to f_dat high, and ending with "f_dat_end."