Skip to content

Instantly share code, notes, and snippets.

@Mizzlr
Last active June 13, 2016 09:02
Show Gist options
  • Save Mizzlr/5034fa966cfc0436aadd48c33f0f382c to your computer and use it in GitHub Desktop.
Save Mizzlr/5034fa966cfc0436aadd48c33f0f382c to your computer and use it in GitHub Desktop.
Most Beautiful Equation Ever
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