Skip to content

Instantly share code, notes, and snippets.

@telliott99
Created December 23, 2020 21:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save telliott99/2c78eb20769e623b69c2c4c69adefa7b to your computer and use it in GitHub Desktop.
Save telliott99/2c78eb20769e623b69c2c4c69adefa7b to your computer and use it in GitHub Desktop.
n = 5
s = 6
cot = 3**0.5
csc = 2
for i in range(n):
Co = s/cot
Ci = s/csc
print(i + 1, '%3.6f' % Co, '%3.6f' % Ci)
cot = cot + csc
csc = (1 + cot**2)**0.5
s *= 2
'''
> python3 pi.py
1 3.464102 3.000000
2 3.215390 3.105829
3 3.159660 3.132629
4 3.146086 3.139350
5 3.142715 3.141032
'''
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment