2 Approximations of π In Only Four Lines of Code!
I just recently noticed I haven't programmed in Python in a while and what better thing to do than approximate π!
After all, it is Pi Python! (Sorry for the poor Markdown rendering. This is supposed to be "Python" with "Py" crossed out and "Pi" inserted.)
(Also, some inspiration from the many π approximation Python repls by
Additionally, I recently completed the codegolf challenges in EcoCode (https://ecocode.mreconomical.repl.co/) by
@MrEconomical . So, why not combine the two?And here are two approximations of π using infinite series in just four lines of code!
By the way, for anyone who is wondering, this is the Nilakantha Series and an infinite series for the radian arctangent of 1 multiplied by 4 (in radians, the arctangent of 1 is π/4, although you might just know it as 45 degrees).
And yes, the arctangent method is VERY slow.
**Update: **
New Node.JS version in just one line:
https://repl.it/@AmazingMech2418/Node-p
Yay! Good work!! ^ ^*
Looks really clean, I must say.
I didn't read it carefully or think about that one, did I?
So sorry....
ᕕ( ᐛ )ᕗ
I don't know how, but I can actually do everyday work on very little sleep. I do not know if that is good, or bad, though..