Skip to content

Instantly share code, notes, and snippets.

View Mizzlr's full-sized avatar

Mushtaque Ahamed A Mizzlr

View GitHub Profile
@Mizzlr
Mizzlr / factorial.output.txt
Created June 13, 2016 09:03
The output generated by factorial.py
╒═════╤════════════════╤═════════════════════╕
│ x │ factorial(x) │ math.factorial(x) │
╞═════╪════════════════╪═════════════════════╡
│ 1 │ 0.999575 │ 1 │
├─────┼────────────────┼─────────────────────┤
│ 2 │ 1.99951 │ 2 │
├─────┼────────────────┼─────────────────────┤
│ 3 │ 5.99942 │ 6 │
├─────┼────────────────┼─────────────────────┤
│ 4 │ 23.9991 │ 24 │
@Mizzlr
Mizzlr / factorial.py
Last active June 13, 2016 09:02
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__':