UsingTree This function finds the factorial of a number using a binary tree
(n int)
| 42 | |
| 43 | // UsingTree This function finds the factorial of a number using a binary tree |
| 44 | func UsingTree(n int) (int, error) { |
| 45 | if n < 0 { |
| 46 | return 0, ErrNegativeArgument |
| 47 | } |
| 48 | if n == 0 { |
| 49 | return 1, nil |
| 50 | } |
| 51 | if n == 1 || n == 2 { |
| 52 | return n, nil |
| 53 | } |
| 54 | return prodTree(2, n), nil |
| 55 | } |
| 56 | |
| 57 | func prodTree(l int, r int) int { |
| 58 | if l > r { |
nothing calls this directly
no test coverage detected