You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
lavos/cap3/ex40.go

19 lines
259 B

7 months ago
package cap3
func Ex40(n int) int {
var fab func(n int) int
fab = func(n int) int {
if n == 1 {
return 1
}
if n == 2 {
return 2
}
return fab(n-1) + fab(n-2)
}
return fab(n)
}