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) 
2
  • 2
    whoa. This: . is a period. It separates lexical groupings we call "sentences" from one another. Please utilize it. Commented Nov 17, 2013 at 5: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. Commented Nov 17, 2013 at 5:55

1 Answer 1

4

Use the decimal module:

>>> import decimal >>> decimal.getcontext().prec = 100 #Set precision >>> decimal.Decimal('22') / decimal.Decimal('7') Decimal('3.142857142857142857142857142857142857142857142857142857142857142857142857142857142857142857142857143') 
Sign up to request clarification or add additional context in comments.

2 Comments

Or maybe fractions, if all the numbers are rational and exact answers really matter.
i tried fractions but the answers were the same, it didn't answer right

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.