Skip to content

Instantly share code, notes, and snippets.

@testingbot
Created December 3, 2013 14:59
Show Gist options
  • Save testingbot/7770538 to your computer and use it in GitHub Desktop.
Save testingbot/7770538 to your computer and use it in GitHub Desktop.
lolcode
HAI
OBTW WE'RE GOING TO CALCULATE PI TODAY USING AN APPROXIMATION ALGORITHM CONSISTING OF CALCULATING THE SUM OF
THE FOLLOWING SERIES:
4 * SUM OF [ (-1)^k k ∈ N
2*k + 1 ]
WE GO UP TO K=1000
TLDR
I HAS A LIMIT ITZ 1000
I HAS A K ITZ 0
I HAS A PI_APPROXIMATION ITZ 0
IM IN YR LOOP UPPIN YR K WILE NOT BOTH SAEM K AN LIMIT
I HAS A NUMERATOR
I HAS A EVEN ITZ MOD OF K AN 2
NOT EVEN, O RLY?
YA RLY, NUMERATOR R 1
NO WAI, NUMERATOR R -1
OIC
I HAS A DENOMINATOR ITZ PRODUKT OF 2 AN K
DENOMINATOR R SUM OF DENOMINATOR AN 1
I HAS A TERM ITZ QUOSHUNT OF NUMERATOR AN DENOMINATOR
PI_APPROXIMATION R SUM OF PI_APPROXIMATION AN TERM
IM OUTTA YR LOOP
PI_APPROXIMATION R PRODUKT OF PI_APPROXIMATION AN 4
VISIBLE "PI IS "!
VISIBLE PI_APPROXIMATION
KTHXBYE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment