Digits of pi | SoloLearn: Learn to code for FREE!

0

Digits of pi

So there is a code in code coach which I need to define the Nth number of decimal for pi but importing it from math would give just 15 decimals I solved this code but not in the best way so I was wondering if there is a syntax or smth that I can do to solve and write this code in cleaner and better way https://code.sololearn.com/czn2ktGgXVJK/?ref=app

10/9/2020 12:31:44 PM

pedram ch

10 Answers

New Answer

+3

https://code.sololearn.com/cIXl46bNLT4c/?ref=app Edit:i see what you mean by the 15 decimals though. you could try mpmath --> https://stackoverflow.com/questions/9004789/1000-digits-of-pi-in-python#13316984 Alright pedram ch , here it is:

+2

Yes, Slick this is not what He is looking for. This one don't work for the 850.th dezimal.

+1

Have look here https://gist.github.com/markhamilton1/9716714

+1

Slick oh I think I should take time to understand it Thank you for sharing

+1

dont even worry about subprocess and sys, thats just how you can import some 3rd party modules. the important stuff is the simplicity of mp.math. you could make your own algorithm if you really wanted to though

+1

Slick now I understand thank you so much for the help

+1

Slick Very nice 👍 I didn't know that.

+1

Import math Print (math.pi)

0

Thomas thank you for the reply I saw the code. It generates the pi to the infinite if im not wrong But my question was let's consider pi as 3.14159 and we want to find fifth decimal of it which is 9 How can we have pi with number of decimals we want not only 15 decimals limit which is in importing it from math

-1

Can one find work with certificate earned from sololearn?