I was working with factorials, I put 1000! and I return NaN. Can you explain why NaN returns? (I think it could be for the bits)

1

asked by Franco Gómez 01.10.2017 в 06:50

source
2

The factorial of 1000 is a number of 2568 digits that does not fit into a Java long whose maximum value is 9,223,372,036,854,775.807 that is, 19 figures. The result NaN means Not a Number, represents an overflow in the calculation. If you really need to calculate the factorial of large numbers there are algorithms based on integer arrays for that.

answered by
01.10.2017 в 08:21