I am doing a fuction that quickly calculates factorial. like this
func factorial(factorialNumber: UInt64) -> UInt64 { if factorialNumber == 0 { return 1 } else { return factorialNumber * factorial(factorialNumber - 1) } } let x = factorial(20)
this function can be calculated up to 20.
I think the factor (21) value is greater than UINT64_MAX.
then how to calculate 21! (21 factorials) in swift?
source share