funcFibonacci(n int)int{ if n == 1 || n == 2 { return1 } return Fibonacci(n-1) + Fibonacci(n-2) }
funcmain(){ for { var input int fmt.Printf("number >>") fmt.Scanf("%d\n",&input) result := Fibonacci(input) fmt.Printf("Fib(%d) result :%d\n",input,result)
} }
result
1 2 3 4 5 6 7 8
number >>3 Fib(3) result :2 number >>4 Fib(4) result :3 number >>5 Fib(5) result :5 number >>6 Fib(6) result :8