Fibonacci Decomposition - MATLAB Cody - MATLAB Central

Problem 42340. Fibonacci Decomposition

Difficulty:Rate

Every positive integer has a unique decomposition into nonconsecutive Fibonacci numbers f1+f2+ ... Given a positive integer n, return these numbers.

Return the vector f = [f1, f2, ...] sorted from smallest to largest. sum(f) = n.

Examples

 n = 3
 f = 3
 n = 32
 f = [3 8 21]

Reference: http://www.johndcook.com/blog/2015/05/17/fibonacci-number-system/

Solution Stats

45.57% Correct | 54.43% Incorrect
Last Solution submitted on May 06, 2025

Problem Comments

Solution Comments

Show comments
LLMs with MATLAB updated to support the latest OpenAI Models
Large Languge model with MATLAB, a free add-on that lets you access...
2
3

Problem Recent Solvers772

Suggested Problems

More from this Author50

Problem Tags

Community Treasure Hunt

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

Start Hunting!
Go to top of page