(Approximate ) can be computed using the following formula:
Write a program that displays the result of
and
Python program:
import math
print("Compute the pi value using the formula")
print(4.0 * (1 - (1.0/3) + (1.0/5) - (1.0/7) + (1.0/9) - (1.0/11)))
print(4.0 * (1 - (1.0/3) + (1.0/5) - (1.0/7) + (1.0/9) - (1.0/11) + (1.0/13)-(1.0/15)))
Output:
Python 3.2.1 (default, Jul 10 2011, 21:51:15) [MSC v.1500 32 bit (Intel)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> ================================ RESTART ================================
>>>
Compute the pi value using the formula
2.9760461760461765
3.017071817071818
>>>