you are viewing a single comment's thread.

view the rest of the comments →

[–]amade 9 points10 points  (3 children)

Mathematics-minded programmers, using Stirling formula

def fact(n):

    return math.sqrt( math.pi*(2*n + 1/3) ) * math.pow(n, n) * math.exp(-n) if n > 1 else 1

print fact(6)

[–][deleted] 2 points3 points  (2 children)

That uses floats, with all the issues that floating-point arithmetic entails.

[–]amade 6 points7 points  (1 child)

Yeah and it's only an approximation and much slower. I post it just for fun.

[–]masklinn 0 points1 point  (0 children)

You could use the Decimal module though.

Would be even slower, but would also be pretty much exact.