Share your repls and programming experiences

← Back to all posts
π in Lua
AmazingMech2418 (1044)

I think I'm pretty much doing pi approximations in every language now, so, here it is in Lua!

I still have the same issue with NASM and am working on that one side-by-side with the other languages. If you can help fix the issue, please let me know at

Here are the other approximations so far:
Dart -
R -
Haskell -
Raku -
Rust -
Go -
Swift -
C# -
Bash -
Kotlin -
Ruby -
Java -
QBasic -
Fortran -
Forth -
Python and Node.js (Node is linked in post) -
C -

Credit to @NoelBryan, @TheForArkLD , @Warhawk947 , and @LizFoster for inspiring these approximations. Most of these use the Nilakantha Series, although I also use the arctangent method (multiplying the radian arctangent of 1 by 4 to get pi and getting the arctangent with an infinite series) in three of them (Python, Node, and C).

Also, credit to @HahaYes and @LizFoster for suggesting Lua!

Next up is F# and then Crystal. (I'm still working on NASM, but can't really tell when I'll be able to get that one done.) If you have any suggestions for after those, please let me know!

TheForArkLD (770)

I can code lua (but bits only)