Skip to content

Instantly share code, notes, and snippets.

@themarcelor
Created February 6, 2022 22:45
Show Gist options
  • Select an option

  • Save themarcelor/7273eb3ade5087ec469a3b8a93671efb to your computer and use it in GitHub Desktop.

Select an option

Save themarcelor/7273eb3ade5087ec469a3b8a93671efb to your computer and use it in GitHub Desktop.
silly fibonacci function in golang
package main
import (
"fmt"
)
func fib(num int) []int {
prev, prevprev := 0, 1
result := []int{}
for i:=0; i < num; i++ {
prev, prevprev = prevprev, prev + prevprev
result = append(result, prev)
}
return result
}
func main() {
fmt.Printf("### the result: %v\n", fib(7))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment