Created
April 16, 2013 11:32
-
-
Save svineet/5395252 to your computer and use it in GitHub Desktop.
Pi calculator. It's accurate for 5 digits after decimal.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def main(): | |
print "Calculating pi. Calm down,bro!" | |
acc = 0.0 | |
for i in range(1,1000001,4): | |
acc += 4/float(i) | |
acc -= 4/float(i+2) | |
print i | |
print "The answer is {0} , brother from another mother!".format(acc) | |
return 0 | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment