Created
December 23, 2020 21:59
-
-
Save telliott99/2c78eb20769e623b69c2c4c69adefa7b to your computer and use it in GitHub Desktop.
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
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