Created
July 7, 2016 10:26
-
-
Save bvanrijn/0f51ca835fca1da62880d5a7b7606e66 to your computer and use it in GitHub Desktop.
Recursive Fibonacci
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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