2 Approximations of π In Only Four Lines of Code!
AmazingMech2418 (1014)

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 @LizFoster )

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.

New Node.JS version in just one line:

You are viewing a single comment. View All
AmazingMech2418 (1014)

@LizFoster For me, enough to function well is 7-8 hours... Are you sure 3-4 hours is enough to function well?