Golang leetcode 509. Fibonacci Number.go

2019-04-12 14:37:32 浏览数 (1)

版权声明:原创勿转 https://cloud.tencent.com/developer/article/1412990

思路

简单的递归

code

代码语言:javascript复制
func fib(N int) int {
	if N == 0 {
		return 0
	}
	if N == 1 {
		return 1
	}
	return fib(N-1)   fib(N-2)
}

0 人点赞