# ChapterArithmetic/compute_pi.py
""" Mathematical equation to compute pi.
pi/4 = 1 - 1/3 + 1/5 - 1/7 + ...
prompts the user for the number of terms
"""
def main():
print("Computation of PI.")
n = int(input( "How many terms for PI? " ))
sum = 0
for i in range( n ):
sum = sum + ((-1)**i) / (2*i+1)
print("PI = ", 4 * sum)
main()