Question

i want to measure about 1000 digits after zero of a number, but i don't know what to do with it to print all of the numbers because it just prints the first 16 numbers what should i do to have them all printed? i tried to change it to string but the problem is that this big number is made by a bigger number which should be the denominator and another problem is that this number is sum of an iterator and i cannot change it to string in each step i tried to make it a product of 10 for example 10^10 or bigger but it didnt answer and it just printed 17 numbers

this is the code:

S=0
for k in range(n+1):
    S+=((factorial(6*k))*(13591409+545140134*k))/((factorial(3*k))*((factorial(k))**3)*((-640320)**(3*k)))
X=((426880*((10005)**0.5))/S)
print(X)
Was it helpful?

Solution

Use the decimal module:

>>> import decimal
>>> decimal.getcontext().prec = 100              #Set precision
>>> decimal.Decimal('22') / decimal.Decimal('7')  
Decimal('3.142857142857142857142857142857142857142857142857142857142857142857142857142857142857142857142857143')
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top