Find the next Fibonacci number - MATLAB Cody - MATLAB Central

Problem 43016. Find the next Fibonacci number

Difficulty:Rate

In the sequence of Fibonacci numbers, every number is the sum of the two preceding ones:

1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, ...

The initial two numbers are generally chosen as [1, 1].

Given one or more integers n, find the next integer that is a Fibonacci number, for each of them.

Example 1:

n = 6;
out = 8;

Example 2:

n = [12 44 50];
out = [13 55 55];

Solution Stats

32.51% Correct | 67.49% Incorrect
Last Solution submitted on Jun 27, 2025

Problem Comments

Solution Comments

Show comments
Why should you share code?
In a discussion on LInkedin about my recent blog post, Do these...
2
3

Problem Recent Solvers736

Suggested Problems

More from this Author2

Problem Tags

Community Treasure Hunt

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

Start Hunting!