The clever authors of the second snippet are rolling their own method of dealing with a very large number such as 50!
. Is rather like a multiprecision library and factorial algorithm rolled into one.
The first snippet has no such consideration. Even 21!
will overflow a signed 64 bit integral type, with undefined results.
solved Factorial Code issue