Question: 1 . a . Write a function ( f i b 1 ( ) ) using iteration, that takes an int (

1.
a. Write a function \( f i b 1()\) using iteration, that takes an int \(\boldsymbol{m a x}\) as input, and calculates and prints all the Fibonacci numbers below max. The function also returns a value indicating how many numbers in the Fibonacci sequence have a value less than max.
b. Write a function fib2() using recursion, that takes an int \(\boldsymbol{n}\) as input, and calculates the \(\boldsymbol{n}^{\text {th }}\) Fibonacci number.
c. Randomly generate an int \(\boldsymbol{m a x}\) between 25 and 250. Call fibl(max) and print the value returned by \( f i b 1()\) with a suitable message.
d. Ask the user to input a number \(\boldsymbol{n}\) between 5 and 16 You can assume the user will enter a valid input in the proper range. Use the function fib2() to generate and print the first \(\boldsymbol{n}\) numbers in the Fibonacci sequence.
Sample outputs (for parts c and d respectively):
1 . a . Write a function \ ( f i b 1 ( ) \ )

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!