Skip to content

Commit 15766f9

Browse files
committed
adds an example
1 parent c8157ac commit 15766f9

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

factorial_example_test.go

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package memoize
2+
3+
import (
4+
"fmt"
5+
)
6+
7+
func ExampleFactorial() {
8+
var factorial func(uint64) uint64
9+
factorial = New(func(i uint64) uint64 {
10+
if i == 0 {
11+
return 1
12+
}
13+
14+
return i * factorial(i-1)
15+
})
16+
17+
fmt.Println(factorial(10))
18+
// Output: 3628800
19+
}

0 commit comments

Comments
 (0)