Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const PHI = (Math.sqrt(5) + 1) / 2
- function divisor (n) {
- if (n === 0) return Math.sqrt(2 + PHI)
- var last = divisor(n - 1)
- return Math.sqrt(2 + last)
- }
- function pi (n) {
- if (n === 0) return 5 / PHI
- var last = pi(n - 1)
- return last * 2 / divisor(n)
- }
- console.log(pi(50))
- //=> 3.1415926535897927
- console.log(Math.PI)
- //=> 3.141592653589793
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement