You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
17 lines
217 B
Go
17 lines
217 B
Go
6 years ago
|
package main
|
||
|
import "fmt"
|
||
|
|
||
|
//using recursion
|
||
|
func fibo(num int) int {
|
||
|
if num <= 1 {
|
||
|
return num
|
||
|
}
|
||
|
return fibo(num -1) + fibo(num - 2)
|
||
|
}
|
||
|
|
||
|
func main(){
|
||
|
num := 10
|
||
|
result := fibo(num)
|
||
|
fmt.Println(result)
|
||
|
}
|