-
-
Save gvitalie/f64bf896e41418986e7a8ef1f5408fe4 to your computer and use it in GitHub Desktop.
π using e^x
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
| me@amadeus:~$ python3 -q | |
| >>> import math | |
| >>> | |
| >>> def exp(x): | |
| ... a = 1 | |
| ... for i in range(1, 30): | |
| ... a += (x ** i) / math.factorial(i) | |
| ... return a | |
| ... | |
| >>> x = 3 | |
| >>> for i in range(3): | |
| ... x += exp(x * 1j).imag | |
| ... | |
| >>> x | |
| 3.141592653589793 | |
| >>> | |
| me@amadeus:~$ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment