Calculer plusieurs milliers de décimales exactes des racines carrées avec cet algorithme.
# exemple racine de 2 def rac(a = 2): b, m, k = 0, 0, 0 while True: if k > 0: a = 100 * (a - b) k += 1 s = 9 while (20 * m + s) * s > a: s -= 1 b = (20 * m + s) * s m = 10 * m + s print(s, end="") if k%25 == 0: print() if k%250 == 0: print(">>",k) input() # exemple racine de 1234567890 def rac2(): n = [12,34,56,78,90] a, b, m, k = 0, 0, 0, 0 while True: a = 100 * (a - b) if k < len(n): a += n[k] k += 1 s = 9 while (20 * m + s) * s > a: s -= 1 b = (20 * m + s) * s m = 10 * m + s print(s, end="") if k%25 == 0: print() if k%250 == 0: print(">>",k) input()