Digits of Pi | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
28th Mar 2020, 9:03 AM
Muhammad Faheem Nasir
Muhammad Faheem Nasir - avatar
3 Answers
+ 4
import numpy as np n = int(input()) p = 2 * 10 ** (n + 4) a = p i = 1 while a > 0: a = a * i // (i * 2 + 1) i += 1 p += a p //= 1000 print(str(p)[-2])
26th Jul 2022, 2:26 AM
HE Miaomiao
+ 3
The description of the task states that you need to figure out up to a 1000 decimal places. Try to print math.pi and see how many decimals you get. So math.pi is not the solution, you got to find another way.
28th Mar 2020, 9:20 AM
HonFu
HonFu - avatar
+ 2
You can type everything by hand (every digit) https://code.sololearn.com/cPkpO2gmACEz/?ref=app
16th Nov 2020, 10:53 PM
Bubbl3mak3r
Bubbl3mak3r - avatar