pi python
# Approximation of the number PI through the Nilakantha's series
from decimal import *
getcontext().prec = 100
s = Decimal(1); #Signal for the next operation
pi = Decimal(3);
n = input("Enter the number of iterations: ")
for i in range (2, n * 2, 2):
pi += (s*(Decimal(4)/(Decimal(i)*(Decimal(i)+Decimal(1))*(Decimal(i)+Decimal(2)))))
s *= -1
print ("Aproximated value of PI :")
print (pi)