Created
August 12, 2011 20:03
-
-
Save epequeno/1142873 to your computer and use it in GitHub Desktop.
fibonacci practice
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import "fmt" | |
//import "strconv" | |
var known = map[int] int{0:0, 1:1} | |
func fibo(n int) (result int) { | |
if value, ok := known[n]; ok { | |
result := value | |
return result | |
} | |
result = fibo(n - 1) + fibo(n - 2) | |
known[n] = result | |
return result | |
} | |
func main() { | |
fmt.Println(fibo(300)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment