Recursive This function recursively computes the factorial of a number
(n int)
| 30 | |
| 31 | // Recursive This function recursively computes the factorial of a number |
| 32 | func Recursive(n int) (int, error) { |
| 33 | if n < 0 { |
| 34 | return 0, ErrNegativeArgument |
| 35 | } |
| 36 | if n <= 1 { |
| 37 | return 1, nil |
| 38 | } |
| 39 | prev, _ := Recursive(n - 1) |
| 40 | return n * prev, nil |
| 41 | } |
| 42 | |
| 43 | // UsingTree This function finds the factorial of a number using a binary tree |
| 44 | func UsingTree(n int) (int, error) { |
nothing calls this directly
no outgoing calls
no test coverage detected