This `fact` function calls itself until it reaches the base case of `fact(0)`.
(n int)
| 9 | // This `fact` function calls itself until it reaches the |
| 10 | // base case of `fact(0)`. |
| 11 | func fact(n int) int { |
| 12 | if n == 0 { |
| 13 | return 1 |
| 14 | } |
| 15 | return n * fact(n-1) |
| 16 | } |
| 17 | |
| 18 | func main() { |
| 19 | fmt.Println(fact(7)) |