Share your repls and programming experiences

← Back to all posts
π in Objective-C
AmazingMech2418 (1103)

Here is a new addition to my series of pi approximations! This one is in Objective-C!

Here are the other approximations so far:
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 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!

Also, thank you to @Atias for inspiring my decision to do this in Objective-C and for helping me with the compiler script!

Comments
hotnewtop
AmazingMech2418 (1103)

Some ideas that I could possibly try for other languages: E, F, Haxe, Vlang, Ada, Racket, Prolog, and maybe Zig.

programmeruser (615)

Isn't this technically cycle farming?

AmazingMech2418 (1103)

@programmeruser I don't see how it is... I'm learning many different programming languages and just posting pi approximations in them.

programmeruser (615)

@AmazingMech2418 you're splitting your approximations into separate posts.

AmazingMech2418 (1103)

@programmeruser Because I'm making them at different times... And they are also different programming languages...

RhinoRunner (864)

do BrainF and Assembly!

AmazingMech2418 (1103)

@RhinoRunner

I have learned Assembly (GAS and NASM), BrainF, and Quil, but these ones don't support floating point in an easy-enough way.