3

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)
thefourtheye
  • 233,700
  • 52
  • 457
  • 497
Omid Karami
  • 2,675
  • 2
  • 13
  • 17
  • 2
    whoa. This: `.` is a period. It separates lexical groupings we call "sentences" from one another. Please utilize it. – roippi Nov 17 '13 at 05:55
  • Python floating point numbers use IEEE 754 representation, which allows for 53 bits, which is 15-17 digits when all is said and done. You likely need a much larger number library to do these calculations. – Joe Nov 17 '13 at 05:55

1 Answers1

4

Use the decimal module:

>>> import decimal
>>> decimal.getcontext().prec = 100              #Set precision
>>> decimal.Decimal('22') / decimal.Decimal('7')  
Decimal('3.142857142857142857142857142857142857142857142857142857142857142857142857142857142857142857142857143')
Ashwini Chaudhary
  • 244,495
  • 58
  • 464
  • 504