Fibonacci excercise (easy) Find the largest Fibonacci number below a given limit
ID: 3778679 • Letter: F
Question
Fibonacci excercise (easy) Find the largest Fibonacci number below a given limit. The Fibonacci sequence is 1, 1, 2, 3, 5, 8, 13, ... The first two values are 1, and each subsequent value is the sum of the previous two values. This function should return the largest element in the sequence smaller than a provided limit. For example, max_fibonacci(10) would return 8. Parameters: upper_limit - The upper limit Return Value: The largest Fibonacci number less than or equal to upper_limit. ================================================== */ int max_fibonacci(int max) { /* ... Your code here ... */ return -1; } /* max_fibonacci */
Explanation / Answer
*/ int max_fibonacci(int max) { int sum=1,sum1=1,answer=0; while(answerRelated Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.