Skip to main content
Submitted by manoj on 21 October 2023
coding-cability

Leonhard Euler (15 April 1707 – 18 September 1783) was a Swiss mathematician, physicist, astronomer, geographer, logician and engineer who founded the studies of graph theory and topology and made pioneering and influential discoveries in many other branches of mathematics such as analytic number theory, complex analysis, and infinitesimal calculus.

Euler provided a proof to calculate value of pi using (yet another) infinite sum, expressed as:

enter image description here

Your job is to write a program to calculate value of pi using first N steps using above formula.

To test the code, give value of N = 1000 or 10,000 or 100,000 or 1,000,000 and see how accuracy increases. How many digits after the decimal point are you getting accurate results?