Created
April 21, 2018 02:25
-
-
Save madumlao/f6bf3498912e178e4092d5c737cced57 to your computer and use it in GitHub Desktop.
Calculates and prints pi
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
from __future__ import print_function | |
def picount(n): | |
count = 2.0 | |
i = 0 | |
j = 1 | |
for k in range(0,n): | |
if k % 2 == 0: | |
i += 2 | |
else: | |
j += 2 | |
count *= i | |
count /= j | |
return count | |
if __name__ == "__main__": | |
print(picount(10000000)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment