Le programme ne fonctionne pas dans l’émulateur mais devrait fonctionner sur votre machine.
D = 102 T = 5 # on veut 5*102 = 500 decimales def unSur(d): r =[0] * D n = 1 for i in range(D): for j in range(T): q = n // d r[i] *= 10 r[i] += q n = (n - q * d) * 10 return r def add(a,b): for i in range(D): v = a[i] + b[i] if v > 10**T and i > 0: a[i-1] += 1 a[i] = v % 10**T return a def atan(x, n): r = [0] * D c = x * x p = 1 for i in range(n): r = add(r,unSur(p * x)) p += 2 if x < 0: r[D - 1] += 1 x *= -c return r def aff(r): for i in range(D): print(("0"*T + str(r[i]))[-T:],end="") def pi(): v = atan(5, 360) w = atan(-239, 106) r = add(v,v) # 2atan(1/5) r = add(r,r) # 4atan(1/5) r = add(r,w) # 4atan(1/5)-atan(1/239) r = add(r,r) r = add(r,r) aff(r)