Share your repls and programming experiences

← Back to all posts
π in Prolog
AmazingMech2418 (1043)

Here is a new addition to my series of pi approximations! This one is in Prolog!

Here are the other approximations so far:
Haxe -
Objective-C -
Pascal -
D -
Scala -
Reason -
Tcl -
C++ -
TypeScript -
CoffeeScript -
Elisp -
Clojure -
Scheme -
Erlang -
Elixir -
Julia -
Nim -
Crystal -
F# -
Lua -
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 @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 adds COBOL, I am definitely looking forward to that one! Also, maybe Vlang 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: E, F, Vlang, Ada, Racket, and Zig

Thank you to @Scoder12 for trying to answer a question of mine with this and for providing me with Method 2 of running my Prolog program.

By the way, Prolog is an interesting language! It basically runs almost like a math equation, the way I put it. Basically, you tell the compiler/interpreter what all is considered to be true, and it figures out the values of undefined variables that are needed for it to be true and processes the variables in that way. Using this, it also makes it into a functional programming language as well, just an unconventional one! Also, this means you can't reuse variables within a function.

AmazingMech2418 (1043)

@DynamicSquid Thank you! :D And I will do Rex if we actually finish it. LOL!

DynamicSquid (4627)

@AmazingMech2418 lol! Well keep up the good work! You can never get enough of pi!

AmazingMech2418 (1043)

Updates: I cannot do E since it won't compile on Also, I won't do F because it is basically just modified Fortran.

AmazingMech2418 (1043)

Also, the Racket installer is too large for