Skip to content
← Back to Community
π in COBOL
Profile icon
AmazingMech2418

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.

Voters
Profile icon
JBloves27
Profile icon
maxina
Profile icon
jsech27
Profile icon
PixiGem
Profile icon
Navinor
Profile icon
programmeruser
Profile icon
TurtleAndrew
Profile icon
MarcusWeinberger
Profile icon
ChopSueyMaster
Profile icon
SilvermoonCat
Comments
hotnewtop
Profile icon
JacobMcPherson1

You should do one in J

Profile icon
Navinor

pog

Profile icon
AmazingMech2418

@Warhawk947 Thank you!

Profile icon
fuzzyastrocat

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)!

Profile icon
AmazingMech2418

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

Profile icon
RayhanADev

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
Profile icon
AmazingMech2418

@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...

Profile icon
RayhanADev

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

Profile icon
AmazingMech2418

@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...

Profile icon
EpicGamer007

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

Profile icon
ANDREWVOSS

Nice

Profile icon
AmazingMech2418

@ANDREWVOSS Thank you!

Profile icon
DynamicSquid

Yay!

Profile icon
JacobMcPherson1

Cool

Profile icon
AmazingMech2418

@JacobMcPherson1 Thank you!

Profile icon
TristanMisja

F#?

Profile icon
AmazingMech2418

@TristanMisja Already done!

Profile icon
TristanMisja
Profile icon
Whippingdot

wut is this...

Profile icon
AmazingMech2418

@Whippingdot COBOL! :D

Profile icon
Whippingdot

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

Profile icon
MesyetiIsTaken

very nice

Profile icon
AmazingMech2418

@MesyetiIsTaken Thank you!

Profile icon
IGamer123

Holy CRAP