Last active
June 13, 2016 09:02
-
-
Save Mizzlr/5034fa966cfc0436aadd48c33f0f382c to your computer and use it in GitHub Desktop.
Most Beautiful Equation Ever
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
import math, tabulate | |
def factorial(x): | |
pi = math.pi | |
e = math.exp(1) | |
exponent = -x + pi ** e / (e ** (2 * pi) * x) + \ | |
pi ** e / (e ** (2 * pi) * x + 2 * pi ** e) | |
return x ** x * math.sqrt(2 * pi * x) * math.exp(exponent) | |
if __name__ == '__main__': | |
table = [] | |
for i in range(1,10): | |
table.append((i, factorial(i), math.factorial(i))) | |
print tabulate.tabulate(table, | |
headers = ("x","factorial(x)","math.factorial(x)"), | |
tablefmt= "fancy_grid") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment