First published at 22:22 UTC on June 17th, 2021.
the last digits of 1/largest prime adding a digit at a time.
#!/usr/bin/python3
from decimal import Decimal
from gmpy2 import mpz, mpq, mpfr
import numpy as np
import os.path
from PIL import Image as im
size = 2000
max_xsize = size
bpath = "frames18…
MORE
the last digits of 1/largest prime adding a digit at a time.
#!/usr/bin/python3
from decimal import Decimal
from gmpy2 import mpz, mpq, mpfr
import numpy as np
import os.path
from PIL import Image as im
size = 2000
max_xsize = size
bpath = "frames18"
path = bpath + "b"
if not os.path.exists(path):
os.makedirs(path)
colors_file="colors2{}.gz".format(max_xsize)
if not os.path.exists("colors{}".format(max_xsize)):
colors = np.zeros(
(max_xsize +1,
3),
dtype=np.uint8
) # create a simple square
for x in range(max_xsize):
color = list(np.random.choice(range(127,255,10), size=3))
colors[x] = color
with open(colors_file,'wb') as o:
args = np.savez(o, colors=colors)
n = mpz(0)
digits = [str(c) for c in range(10)]
res = ""
scale= mpz(10)
def render(n, page):
imgd = np.zeros((size,size,3),dtype=np.uint8)
for i,l in enumerate(page):
for j,c in enumerate(l):
if c == '.':
continue
x = int(c)
color = colors[x]
imgd[i][j][0]= color[0]
imgd[i][j][1]= color[1]
imgd[i][j][2]= color[2]
return imgd
with open("big.txt") as fi:
for l in fi:
last =""
page = []
for c in l:
if c not in digits:
continue
n = n + mpz(1)
scale = scale * mpz(100)
res2 = res + c
if n> 5:
m = mpq(mpz(1),mpz(res2))
m1 = mpfr(m,n*3)
last1 = str(m1)
#diff = abreak(last, last1)
stop = len(last1)
for i,b in enumerate(last1):
if b == 'e':
stop = i
line = last1[stop-size:stop]
page.append(line)
if len(page) > size:
page.pop(0)
np1 = render(n,page)
data = im.fromarray(np1)
name = '%s/%s_%08d.jpeg' % (path, "scan", n)
data.save(name)
last = last1
res = res2
LESS