Skip to content

Instantly share code, notes, and snippets.

@bvanrijn
Created July 7, 2016 10:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bvanrijn/0f51ca835fca1da62880d5a7b7606e66 to your computer and use it in GitHub Desktop.
Save bvanrijn/0f51ca835fca1da62880d5a7b7606e66 to your computer and use it in GitHub Desktop.
Recursive Fibonacci
package main
import "fmt"
func F(n int) int {
if n == 0 { return 0 }
if n == 1 { return 1 }
return F(n-2) + F(n-1)
}
func main() {
fmt.Println(F(35))
}
def F(n):
if n == 0: return 0
if n == 1: return 1
return F(n-2) + F(n-1)
print(F(35))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment