Share your repls and programming experiences

← Back to all posts
π in Zig and V
AmazingMech2418 (1102)

Here is a new addition to my series of pi approximations! This post includes approximations in Zig and V!

Here are the other approximations so far:
Prolog - https://replit.com/talk/share/p-in-Prolog/133312
Haxe - https://replit.com/talk/share/p-in-Haxe/133103
Objective-C - https://replit.com/talk/share/p-in-Objective-C/117733
Pascal - https://repl.it/talk/share/p-in-Pascal/115831
D - https://repl.it/talk/share/p-in-D/42887
Scala - https://repl.it/talk/share/p-in-Scala/42025
Reason - https://repl.it/talk/share/p-in-Reason/42012
Tcl - https://repl.it/talk/share/p-in-Tcl/41996
C++ - https://repl.it/talk/share/p-in-C/41882
TypeScript - https://repl.it/talk/share/p-in-TypeScript/41874
CoffeeScript - https://repl.it/talk/share/p-in-CoffeeScript/41867
Elisp - https://repl.it/talk/share/p-in-Emacs-Lisp-Elisp/41846
Clojure - https://repl.it/talk/share/p-in-Clojure/41845
Scheme - https://repl.it/talk/share/p-in-Scheme/41844
Erlang - https://repl.it/talk/share/p-in-Erlang/41652
Elixir - https://repl.it/talk/share/p-in-Elixir/41530
Julia - https://repl.it/talk/share/p-in-Julia/41395
Nim - https://repl.it/talk/share/p-in-Nim/41372
PHP - https://repl.it/talk/share/p-in-PHP/41348
Crystal - https://repl.it/talk/share/p-in-Crystal/41276
F# - https://repl.it/talk/share/p-in-F/41261
Lua - https://repl.it/talk/share/p-in-Lua/41251
Dart - https://repl.it/talk/share/p-in-Dart/41240
R - https://repl.it/talk/share/p-in-R/41205
Haskell - https://repl.it/talk/share/p-in-Haskell/41199
Raku - https://repl.it/talk/share/p-in-Raku/41111
Rust - https://repl.it/talk/share/p-in-Rust/41056
Go - https://repl.it/talk/share/p-in-Go/40950
Swift - https://repl.it/talk/share/p-in-Swift/36150
C# - https://repl.it/talk/share/p-in-C/36141
Bash - https://repl.it/talk/share/p-in-Bash/36133
Kotlin - https://repl.it/talk/share/p-in-Kotlin/36125
Ruby - https://repl.it/talk/share/p-in-Ruby/34982
Java - https://repl.it/talk/share/p-in-Java/34978
QBasic - https://repl.it/talk/share/p-in-QBasic/34973
Fortran - https://repl.it/talk/share/p-in-Fortran/34890
APL - https://repl.it/talk/share/p-in-APL/34888
Forth - https://repl.it/talk/share/p-in-Forth/34652
LOLCODE - https://repl.it/talk/share/p-in-LOLCODE/34421
Python and Node.js (Node is linked in post) - https://repl.it/talk/share/2-Approximations-of-p-In-Only-Four-Lines-of-Code/32773
C - https://repl.it/talk/share/p-Approximations-in-C/33461

Credit to @NoelB33 @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).

This series is mostly over, but if I learn a new programming language that has floating point capabilities, get ready for a new addition! I have learned Assembly (GAS and NASM), BrainF, and Quil, but these ones don't support floating point in an easy-enough way. LOL! If Repl.it adds COBOL, I am definitely looking forward to that one! Also, maybe Ada next? Let me know what you think!

Also, I'm planning on making a powerful compiled language called Peregrine soon and an object-oriented variant called Falcon and will make pi approximations in both to add to the series!

Ideas for the next ones: Ada and anything else any of you come up with

Thank you to @Atias for the template!

By the way, the Zig program is accurate to 21 places! Most of them are only accurate to 15!

Comments
hotnewtop
DynamicSquid (5023)

Can you try Night? I can provide you with a template :)

DynamicSquid (5023)

@AmazingMech2418 Actually, I don't think there's even a stable version for Night right now LOL! But once I release a stable version I can let you know :)

Warhawk947 (524)

this is a certified bobux moment

firefish (953)

@AmazingMech2418 he's off again making pi in languages that nobody has ever even heard of before