Share your repls and programming experiences

← Back to all posts
π in Java
h
AmazingMech2418 (894)

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

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

<3
<3
<3

you are a god

[deleted]

are you kidding me????
you are in any palce code any lang????
and PI!!!!!

AmazingMech2418 (894)

@Zuhdi28 Well, I can program in any language, as long as I'm given the documentation...

[deleted]

@AmazingMech2418 that's cool!

oignons (308)

Do it in binary next. >:)
Or, if that's too scary rn, BrainF.
Or c++.

AmazingMech2418 (894)

@ipastrano Unfortunately, Repl.it doesn't have a hex editor (and I also think Assembly would be better before binary...). Also, I'm probably going to save the esolangs for last (well, besides LOLCODE which I just did for a proof of concept really). Also, since C and C++ are so similar (and even share compilers), I'm not currently planning on doing it in C++ as well since I could just copy everything into a C++ repl and it should work.

Jakman (450)

Now do it in assembly language.

AmazingMech2418 (894)

@Jakman LOL! I'm actually planning on it eventually after I learn it...

Jakman (450)

@AmazingMech2418 good. if you do that then i will upvote all of your posts from then on. Also if u wanna do it in C# i will definitely help.

ChezCoder (1498)

Suggestion: Do HTML / CSS next... If you somehow find a way to do it in those 2 langs, I will upvote all of your projects.

AmazingMech2418 (894)

@ChezCoder Actually, one issue: HTML and CSS are markup and stylesheet languages respectively, not programming languages.

AmazingMech2418 (894)

@ChezCoder The closest you can possibly get: https://repl.it/@AmazingMech2418/HTMLCSS-Pi By the way, I already tried keyframes with iterating a variable. It doesn't work...

Roar123 (430)

@AmazingMech2418 You can calculate in JS and display the results in HTML/CSS

AmazingMech2418 (894)

@Roar123 It is supposed to be just HTML/CSS...

Roar123 (430)

@AmazingMech2418 What's the point of that :)

AmazingMech2418 (894)

@CodingCactus Basically, what I did in the closest thing to it example... I just did it from memory with 46 digits...

ChezCoder (1498)

@AmazingMech2418 yes thats the point, their markup/styling languages

ChezCoder (1498)

@AmazingMech2418 But still, I have upvoted all of your projects. Well deserved :D