Try looking at the results of the fact
function as you increase n
. You will see that something goes wrong.
This is due to the fact that standard Julia integers (Int64
) have a maximum possible size that they can store. A solution to this is to use BigInt
instead.
A better solution is to rewrite your code (if possible) so that you don’t actually need to compute the whole factorial.