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)
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)
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.