π in R
h
AmazingMech2418 (693)

I think I'm pretty much doing pi approximations in every language now, so, here it is in R!

I was going to do NASM before R (and actually before Raku Haskell even), but ran into some issues with floating point numbers that I'm currently working on fixing (if you know how to fix it, please tell me here: https://repl.it/talk/ask/NASM-Print-Floating-Point/41105).

Here are the other approximations so far:
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 @NoelBryan, @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).

Also, credit to @HahaYes for inspiring this approximation in R!

Next up is NASM (Assembly; only if I can actually figure it out. I might have to save it for later since it is so difficult to program in. I keep pushing it back anyways due to issues with printing floating point numbers), followed by Dart. If you have any suggestions for after those, please let me know!

You are viewing a single comment. View All
AmazingMech2418 (693)

@Jakman I already did C, so I am not planning on doing C++ since they are both so similar. That is the same reason why I'm not doing BASIC since I already did QBasic.

Jakman (377)

@AmazingMech2418 sounds good. What about F#. It is C# but functional. Also no curly brackets or semicolons in there either.

AmazingMech2418 (693)

@Jakman Might do that one after Lua...

Jakman (377)

@AmazingMech2418 sounds good. I will look forward to that.

AmazingMech2418 (693)

@Jakman :D I'm about to post the Dart one now. Dart seems like a mixture between C++ and JavaScript with a sprinkle of Python...

Jakman (377)

@AmazingMech2418 to me it is a mix of kotlin and java. Anyways i will be there to check it out.

AmazingMech2418 (693)

@Jakman I was about to say it was sort of like a mixture of Kotlin and Java too, but I'm more familiar with JavaScript, although I do know Kotlin and Java pretty well now, and Dart is prototypal OOP like JS.

Jakman (377)

@AmazingMech2418 it looks like it will take off. But i fear that it will be in the same status of ruby. rather than a more mainstream language.

AmazingMech2418 (693)

@Jakman Yeah. Though, it is a language by Google and we already saw how much success Go got (it was supported by Google, although not made by them)... By the way, I just posted the approximation in Dart!

Jakman (377)

@AmazingMech2418 yes. I will check the post out now and like it instantly to get it to hot.