Share your repls and programming experiences

← Back to all posts
##### π in Go

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

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

hotnewtop
TheForArkLD (770)

Cool..... i waited it....

AmazingMech2418 (1046)

@TheForArkLD Thank you! (you mean "wanted", right?)

AmazingMech2418 (1046)

@TheForArkLD Do you mean "waited for it" then?

AmazingMech2418 (1046)

@TheForArkLD Okay. That makes sense. I knew it was either "I wanted it" or "I waited for it", but couldn't figure out which.

AmazingMech2418 (1046)

@CodeLongAndPros I actually finally figured out how to get NASM to work on Repl.it, so I might do that after Rust...

AmazingMech2418 (1046)

@theangryepicbanana I might try Raku after NASM which will be after Rust. At that point, I'll have to decide between Haskell or Raku. (probably Raku though since Haskell is weird)

theangryepicbanana (1694)

@AmazingMech2418 ok cool (and if you want to get real fancy with the raku one, you can even use the unicode pi symbol in place of `pi`)

AmazingMech2418 (1046)

@theangryepicbanana Cool! I think some of the other languages support unicode symbols (I know Python does), but I didn't know Raku did. (Raku is the same as Perl6, right?)

theangryepicbanana (1694)

@AmazingMech2418 Yeah all unicode works in Raku. Re: Perl 6, yes, Raku is the new name for Perl 6

Rovy (10)

I don't really understand what its supposed to do but its still cool

AmazingMech2418 (1046)

@Rovy Thank you! This simply approximates pi using the Nilakantha Series.

Rovy (10)

no idea what you're talking about but shur you're welcome and can you upvote me plz @AmazingMech2418

Rovy (10)

(if you haven’t already cuz i new to this talk)

rediar (503)

Do it in Rust next!

AmazingMech2418 (1046)

@rediar I actually was thinking about doing Rust next since it is such a fast-growing language!

rediar (503)

@AmazingMech2418 Yeah, I just took up rust a month ago, pretty cool, harder then python, but just about everything is. :) looking forward to it

Jakman (453)

Hey remember that one challenge we had against each other a month ago? I challenge you again. I'll use Rust this time if you want to accept the challenge.

xxpertHacker (928)

I forgot you're still doing this, using the same algorithm over and over is boring, change it up, go do a Monte Carlo sequence in Haskell or something.

AmazingMech2418 (1046)

@StudentFires Well, I might do Haskell after NASM which I'm probably going to do after Rust. Also using the same algorithm is partially to test the speeds of the different languages with the same algorithm. Also, it is just easier to stick with an algorithm I know pretty well that is also efficient.

HahaYes (1863)

wait..... you forgot R! I'm going to do that

AmazingMech2418 (1046)

@HahaYes I'll probably do R with the Nilakantha Series after Raku and Haskell which will both be after NASM which will be after Rust.

HahaYes (1863)

@AmazingMech2418 wait you haven't done Rust yet!!!!

AmazingMech2418 (1046)

@HahaYes Nope. I haven't done these in a while, so the last one I did was Swift.

HahaYes (1863)

oh no we starting this again

AmazingMech2418 (1046)

@HahaYes What? Learning new programming languages and making pi approximators in them? I don't see what is bad about that...

HahaYes (1863)

@AmazingMech2418 it is just funny,(cough cough great way to get cycles)

AmazingMech2418 (1046)

@HahaYes Sorry for the late response, but honestly, this is not about cycles and stuff. I just want to learn more programming languages and pi approximators are a good way to learn the basics of those languages. Then, of course, posting the repls gives others the opportunity to see the languages and possibly start to learn them.