mirror of
https://github.com/unknwon/the-way-to-go_ZH_CN.git
synced 2025-08-12 06:23:59 +08:00
update book code
This commit is contained in:
18
eBook/exercises/chapter_7/fibonacci_array.go
Executable file
18
eBook/exercises/chapter_7/fibonacci_array.go
Executable file
@@ -0,0 +1,18 @@
|
||||
package main
|
||||
|
||||
import "fmt"
|
||||
|
||||
var fibs [50]int64
|
||||
|
||||
func main() {
|
||||
fibs[0] = 1
|
||||
fibs[1] = 1
|
||||
|
||||
for i:= 2; i < 50; i++ {
|
||||
fibs[i] = fibs[i-1] + fibs[i-2]
|
||||
}
|
||||
|
||||
for i:=0; i < 50; i++ {
|
||||
fmt.Printf("The %d-th Fibonacci number is: %d\n", i, fibs[i])
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user