Exercise: Compute the Fibonacci Number
Write code to solve the problem.
Question
Write a function that computes the Fibonacci number.
- The function should be called
fiband should take as input a single integer value in a variablen. It should return an integer value representing the Fibonacci number. - The function should use a loop instead of recursion.
Sample input:
fib(4)
Sample output:
3
Exercise: Compute the Fibonacci Number
Write code to solve the problem.
Question
Write a function that computes the Fibonacci number.
- The function should be called
fiband should take as input a single integer value in a variablen. It should return an integer value representing the Fibonacci number. - The function should use a loop instead of recursion.
Sample input:
fib(4)
Sample output:
3