Skip to content

Instantly share code, notes, and snippets.

@rxrav
Last active March 8, 2020 12:03
Show Gist options
  • Save rxrav/b29f217e1c593fcb89c055f7e1a31d5b to your computer and use it in GitHub Desktop.
Save rxrav/b29f217e1c593fcb89c055f7e1a31d5b to your computer and use it in GitHub Desktop.
Fibonacci series implementation using recursion technique in Golang
package main
import "fmt"
var rCounter int
func fibRec(i int) int {
rCounter++
if i == 1 {
return 0
} else if i == 2 {
return 1
} else {
return fibRec(i-1) + fibRec(i-2)
}
}
func main() {
fmt.Println(fibRec(16))
fmt.Println("Called function", rCounter, "times")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment