bigFactorial returns the factorial of n as a big.Int Use big package to handle large numbers
(n int)
| 27 | // bigFactorial returns the factorial of n as a big.Int |
| 28 | // Use big package to handle large numbers |
| 29 | func bigFactorial(n int) *big.Int { |
| 30 | if n < 0 { |
| 31 | return big.NewInt(0) |
| 32 | } |
| 33 | if n == 0 { |
| 34 | return big.NewInt(1) |
| 35 | } |
| 36 | return big.NewInt(0).Mul(big.NewInt(int64(n)), bigFactorial(n-1)) |
| 37 | } |