Shembull: Fibonacci sekuenca

package main

import "fmt"

func main() {
    var fib = []int{0, 1}
    var s int
    for i := 1; i <= 18; i++ {
        s = fib[i-1] + fib[i]
        fib = append(fib, s)
    }

    fmt.Println(fib)
}

https://play.golang.org/p/mSt9Ezn5E7G

Rezultati:

[0 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 1597 2584 4181]
All Rights Reserved Theme by 404 THEME.