Last Updated: February 25, 2016
·
5.93K
· donutdan4114

Calculating Pi using JavaScript

During my time calculating Pi using PHP ( http://coderwall.com/p/g35wya?i=1&p=1&q= ), I decided it was time to try it with JavaScript.

Here is the jsFiddle: http://jsfiddle.net/WfpzT/4/
Picture

This script will allow you to enter an accuracy number and then calculate Pi using that number of iterations. The higher the accuracy, the more accurate your Pi calculations will be.

More information about this method of calculating Pi can be found here: http://en.wikipedia.org/wiki/Leibniz_formula_for_%CF%80

Have a fresh tip? Share with Coderwall community!

Post
Post a tip
Did you know?

JavaScript on a page runs with the privileges of that origin. One altered library, tag manager, or snippet can read inputs, change what people see, and call your APIs as the user.

Security insights from Cside