通常fibanocci要两个递归调用 复杂度o(2^n)
但是用指针的话,可以只用1次call 复杂度 o(n)
(10 minutes) Write a program called fib.c that calculates the nth fibanocci
number. The equation for the Fibonacci numbers is defined as follows:
Fib(0)=0
1.
Fib(N)=Fib(N−1)+Fib(N−2)
- Name your executable fib.out
- Your program should accept N as a command line argument
- You MUST solve this program RECURSIVELY
- Unlike the example in class, you may only have ONE RECURSIVE CALL in
your function
1. Hint pointers help make this possible.
- Here are the first 100 numbers in the Fibonacci sequence
- Examples
1../fib.out 0
The 0th fibanocci number is 0.2../fib.out 1
The 1th fibanocci number is 1.3../fib.out 10
The 10th fibanocci number is 55.