Skip to content

Instantly share code, notes, and snippets.

@teyyihan
Created December 9, 2020 11:34
Show Gist options
  • Save teyyihan/adee9dcee5070e6c43744e50ed78cb58 to your computer and use it in GitHub Desktop.
Save teyyihan/adee9dcee5070e6c43744e50ed78cb58 to your computer and use it in GitHub Desktop.
func main() {
d := make(map[int]int)
t0 := time.Now()
fmt.Println(fib(40))
t1 := time.Now()
fmt.Println(memoFib(40,d))
t2 := time.Now()
fmt.Println("It took ",t1.Sub(t0).Nanoseconds()," nanoseconds to calculate without memoization")
fmt.Println("It took ",t2.Sub(t1).Nanoseconds()," nanoseconds to calculate with memoization")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment