pi1860.py

Created by schraf

Created on July 22, 2022

450 Bytes

Calculer 1860 décimales exactes en moins de 35 secondes sur une NUMWORKS (N110), c’est possible

Pour la NUMWORKS ancienne génération (N100), remplacez 6525 par 2227 et 6524 par 2226, ce qui vous donnera 635 décimales exactes.

Mes vidéos autour des décimales de pi :

En route vers les décimales de Pi : partie 1 - découvrons les formules de MACHIN

En route vers les décimales de Pi : partie 2 - programme Python


def pi():
    r = [2000] * 6525
    r[6524] = 0
    c = 0
    a = 10000
    for k in range(6524,0,-14):
        d = 0
        i = k
        while True:
            d += r[i] * a
            b = 2 * i - 1
            r[i] = d % b
            d //= b
            i -= 1
            if i == 0: break
            d *= i
        v = c + d // a    
        print("{0:04d}".format(v),end="")
        if k%5 == 0: print()
        c = d % a
pi()

During your visit to our site, NumWorks needs to install "cookies" or use other technologies to collect data about you in order to:

With the exception of Cookies essential to the operation of the site, NumWorks leaves you the choice: you can accept Cookies for audience measurement by clicking on the "Accept and continue" button, or refuse these Cookies by clicking on the "Continue without accepting" button or by continuing your browsing. You can update your choice at any time by clicking on the link "Manage my cookies" at the bottom of the page. For more information, please consult our <a href="https://www.numworks.com/legal/cookies-policy/">cookies policy</a>.