Question: 2. A. In main(),declare a variable N, input an integer (positive and less than 30) from standard input (keyboard); based on the value of N,
2. A. In main(),declare a variable N, input an integer (positive and less than 30) from standard input (keyboard); based on the value of N, use a loop to calculate the Nth Fibonacci number and print the result.
B. Define a recursive function to calculate Fibonacci numbers. In main(), assign N with an integer (positive and less than 20) from standard input. Based on the value of N, call the recursive function and output the Nth Fibonacci number: Fibonnacci(N) = Fibonacci(N-1) + Fibonacci(N-2) Note: The first two Fibonacci numbers are given as 1 and 1. Each Fibonacci number is the sum of its preceding two numbers, see above equation.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
