Get a Fibonacci number's index. - MATLAB Cody - MATLAB Central

Problem 2982. Get a Fibonacci number's index.

Difficulty:Rate

N.B. For the purpose of this exercise, the first Fibonacci number is 1, and the second is 2; that is, fib(1) = 1 and fib(2) = 2 .

Make a function isfib(x) so that:

  • if the value of the input x is not a Fibonacci number, the function returns a zero.
  • if the value of the input x is a Fibonacci number, the function returns its index in the Fibonacci sequence. That is, isfib(fib(n)) should return the value of n .

Solution Stats

34.23% Correct | 65.77% Incorrect
Last Solution submitted on Apr 21, 2025

Problem Comments

Solution Comments

Show comments
Registration Now Open for MathWorks AUTOMOTIVE CONFERENCE 2025
...
Hello Community, We're excited to announce that registration is now open for the...

Problem Recent Solvers46

Suggested Problems

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Go to top of page