Advertisement
JustMinecraftPlayer

Calculate PI using HTML

Jun 19th, 2022
1,101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 0.54 KB | None | 0 0
  1. <div id="rpi"></div><hr>
  2. <div id="pi"></div>
  3. <script>
  4.     //PI search
  5.     function a (n){
  6.         return (n/(n-1))*(n/(n+1))
  7.     }
  8.     c=2
  9.     d=2
  10.     function b(){
  11.         d = d*a(c)
  12.         c = c+2
  13.         document.getElementById("pi").innerHTML = d +"<br>("+c/2+ " calculation)<br><strong>Calculating PI can take a while, you will need around 1,000,000 calculation.</strong>"
  14.     }
  15.     setInterval(b,1)
  16.     document.getElementById("rpi").innerHTML = "Expected Output:<br>"+Math.PI
  17.     // Calculation Inspired By 3Blue1Brown
  18. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement