Skip to content

Instantly share code, notes, and snippets.

@madumlao
Created April 21, 2018 02:25
Show Gist options
  • Save madumlao/f6bf3498912e178e4092d5c737cced57 to your computer and use it in GitHub Desktop.
Save madumlao/f6bf3498912e178e4092d5c737cced57 to your computer and use it in GitHub Desktop.
Calculates and prints pi
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