Share your repls and programming experiences

← Back to all posts
π in COBOL
AmazingMech2418 (1104)

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

Here are the other approximations so far:
Ada - https://replit.com/talk/share/p-in-Ada/134278
Zig + V - https://replit.com/talk/share/p-in-Zig-and-V/133483
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! Which one should I do 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: Open to suggestions!

Also, thank you to @DynamicSquid for most recently suggesting COBOL on my post in Ada.

Comments
hotnewtop
JacobMcPherson1 (241)

You should do one in J

fuzzyastrocat (1896)

Dang I need to make faster progress on Eros so I can get you to do one of these in it xD

Nicely done (though ewww COBOL)!

AmazingMech2418 (1104)

@fuzzyastrocat Thank you! Hey, COBOL is actually pretty cool, I think! LOL!

RayhanADev (2697)

Yay! Another one in the series :D

Also have you done BASIC? (not QBasic which I know you know, just BASIC)

Edit:

  • Applescript
  • WASM
  • HolyC
AmazingMech2418 (1104)

@RayhanADev Thank you! :D

And I have not done one in normal BASIC, but really the main difference between the two is that BASIC has the GUI, and a pi approximator doesn't really need that...

RayhanADev (2697)

@AmazingMech2418 ah gotcha (also I updated comment with a few random languages off the top of my head lol)

AmazingMech2418 (1104)

@RayhanADev With AppleScript, I'm pretty sure that's Mac-only, so I don't think I can do it on Repl.it and I can't do it off Repl.it because I don't have a Mac.

WASM is actually one I'm thinking about trying! I need to learn it a little more though.

Judging from a few Google searches, that one only runs on TempleOS...

EpicGamer007 (1794)

@AmazingMech2418 @RayhanADev wasm is a compile target, i think you meant wat. (I dont think AM2418 would want to write machine code lol)

Whippingdot (720)

my brain does not comprehend the words you are speaking oh amazing mech who wants to take over the world of fortnite @AmazingMech2418