Leibniz formula for Pi. When it is solved for Pi one gets:
Pi=4/1-4/3+4/5-4/7...
And so on since it's an infinite series. Since one can see a pattern that can
easily be defined I concluded that a simple program using a loop could be made.
I decided on using JavaScript for its ease of use and use a for loop. The
program I made at first was mainly:

var Pi=0;
var n=1;
for (i=0;i<=1000;i++)
{
Pi=Pi+(4/n)
n=n+2
Pi=Pi-(4/n)
n=n+2
}

Where the variable "Pi" is the value of Pi, "i" is the number of times the loop
is repeated, and "n" is just a variable to help in the formula. This I however
found could further simplified to:

var Pi=0;
var n=1;
for (i=0;i<=1000;i++)
{
Pi=Pi+(4/n)-(4/(n+2))
n=n+4
}

Of course the more times the loop is repeated, the more accurate your value of
Pi gets, and while 1000 may seem like a large number, the value of Pi which it
calculated is wrong after the 3rd decimal point. I've had it repeat over 100,000
times and it gets more accurate, however, remember that making the number of
repeats can slow down and even crash your browse

The maximum decimal places in javascript is limited to15.
So you cannot get more than 15 decimal places.

Viete's Series
The first infinite sequence discovered in Europe was an infinite product, found
by French mathematicianFrançois
Viètein
1593:

Wallis's Series
The second infinite sequence, found in Europe byJohn
Wallisin
1655, was also an infinite product:

Leibniz's Series
Madhava of Sangamagrama,
a Indian mathematician, formulated a series that was rediscovered by scottish
mathematicianJames
Gregoryin
1671, and byLeibnizin
1674:

Nilakantha's Series
An infinite series for PI published byNilakanthain
the 15th century is:

The calculation ends when two consecutive results are the same.
The accuracy of π improves by increasing the number of digits for calculation.

In 1914, the Indian mathematician Ramanujan discovered the formula for computing
Pi that converges rapidly.
In 1987, Chudnovsky brothers discovered the Ramanujan-type formula that
converges more rapidly.