Created
December 7, 2018 14:25
-
-
Save zwfang/ceb2d002b3a9662c8ef20735ec5a7d37 to your computer and use it in GitHub Desktop.
fib
This file contains 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" | |
func fib() func() int64 { | |
var i int64 | |
var j int64 = 1 | |
return func() int64 { | |
i, j = j, i+j | |
return i | |
} | |
} | |
func main() { | |
a := fib() | |
pre := (float64)(a()) | |
for k := 1; k < 50; k++ { | |
cur := (float64)(a()) | |
fmt.Println(pre / cur) | |
pre = cur | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment