"$n * log ($n) - e* log($n) + 0.5 * (log(2*PI)+log($n));"
Stirling's approx is n^ne^{-n}sqrt{2 pi n), so when you take
the log, you get nlog(n) - nlog(e) + .5(log(2pi)+log(n))
so it appears one of your terms is incorrect. (Why not use
natural log anyway?)
In addition Stirling's gives an asymptotic approximation
(the ratio of Stirling's expression to n! is close to 1 for large n; it is not true that the expresion is close to n! for large n.)
chas