Share your repls and programming experiences

← Back to all posts
π in Kotlin
h
AmazingMech2418 (830)

I think I'm pretty much doing pi approximations in every language now, and I recently learned that Kotlin is expected to beat Java in Android development, so I decided to learn the basics of Kotlin, and here is pi in Kotlin!

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

Commentshotnewtop
Jakman (438)

string interpolation is a bit different in kotlin then hm...

AmazingMech2418 (830)

@Jakman Yeah... Not much different though...

AtriDey (168)

I actually did a Nilakantha series in Python a day before I saw this, but I got 3.14159265358984 instead of 3.14159265358979.

AmazingMech2418 (830)

@AtriDey Try increasing the iterations. :)

AtriDey (168)

@AmazingMech2418 It's going infinitely, and it just stopped there. maybe if I leave it for a day to do more iterations... -_-

AmazingMech2418 (830)

@AtriDey Maybe? I don't know. I did one in Python too a while back (see the list in this post).

AtriDey (168)

@AmazingMech2418 I would get to start running the repl but now nothing works, I broke repl.it again. Fourth time this week; and it's only Tuesday.

AmazingMech2418 (830)

@AtriDey What do you mean you broke Repl.it? Is that why the connections are failing?

AtriDey (168)

@AmazingMech2418 Wait, it fails for you too? I guess repl.it is down, Cloudfare gave me some sort of notice when I checked the markdown doc.

AtriDey (168)

@AmazingMech2418 My brain is broken the fifteenth time this week, and it's only Wednesday.

AmazingMech2418 (830)

@AtriDey I'm getting the "Failed to connect, retrying notifications".

AtriDey (168)

@AmazingMech2418 Same. Guess it's time to torture the repl.it team by joining the crusade of error reports.

AmazingMech2418 (830)

@AtriDey LOL! I don't think that is necessary...

Code1Tech (14)

oof i got so many errors

AmazingMech2418 (830)

@Code1Tech Apparently, Repl.it updated to use correct Kotlin.

CodingCactus (3034)

great! What lang is next?

AmazingMech2418 (830)

@CodingCactus I'm not really sure. Probably either Swift or Go. I'm still learning Assembly though and might have to do that one later on. Do you have any suggestions?

CodingCactus (3034)

@AmazingMech2418 erm, i'll have a look at the list of languages and see which ones have cool names :)

AmazingMech2418 (830)

@CodingCactus For that, I've already done all of the classic languages, have done all of the popular ones besides Scheme, Go, and Rust, and plan on doing esolangs last.

AmazingMech2418 (830)

@CodingCactus A pretty much failed multipurpose language by Google. It is normally compiled into JavaScript for web development I think.

CodingCactus (3034)

@AmazingMech2418 lol, idk I'm just saying languages with nice names

AmazingMech2418 (830)

@CodingCactus LOL! I think Quil would be interesting, but it seems like a fairly new language anyways, so maybe save that one for later (definitely going to do it though)?

AmazingMech2418 (830)

@NoelBryan I already did QBasic and BASIC is really just the same in syntax and functions.

NoelB33 (314)

Ok, the first one I found on languages was emacs lisp @AmazingMech2418

AmazingMech2418 (830)

@NoelBryan I've looked at Lisp before and I'm probably going to save the Lisp dialects for later.

NoelB33 (314)

Idk what bash is, but try it @AmazingMech2418

AmazingMech2418 (830)

@NoelBryan Bash - The classic Bourne Again SHell on all Linux devices. You're right, I should try it!

TheForArkLD (711)

@AmazingMech2418 I have idea!
(but this is my own language)
Lets do DefLang!

var defl=require('deflang')
var fs=require('fs')
defl(fs.readFileSync('main.dfl').toString(),'--stdout')

(Not Esolang)