Write a Python function to print First n Digits of Pi
Topic: Write a Python function to print First n Digits of Pi
Solution
def pi(n): i = 1 p = x = 3 * 10 ** (n + 10) while x: x = x * i // ((i + 1) * 4) i += 2 p += x // i return '3.' + f"{p // 10 ** 10}"[1:] print(pi(7))
List all Python Programs