Cody

Problem 43016. Find the next Fibonacci number

Solution 2654684

Submitted on 5 Jul 2020 by Abdelfatah Teamah
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

Test Suite

Test Status Code Input and Output
1   Pass
n = 6; out = 8; assert(isequal(next_fibonacci(n),out));

seq = 1 1 2 3 5 8 a = 8 y = 8

2   Pass
n = [12 40 50]; out = [13 55 55]; assert(isequal(next_fibonacci(n),out));

seq = 1 1 2 3 5 8 13 21 34 55 a = 13 21 34 55 a = 55 a = 55 y = 13 55 55

3   Pass
n = 10.^(1:5); out = [13 144 1597 10946 121393]; assert(isequal(next_fibonacci(n),out));

seq = Columns 1 through 15 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 Columns 16 through 26 987 1597 2584 4181 6765 10946 17711 28657 46368 75025 121393 a = Columns 1 through 15 13 21 34 55 89 144 233 377 610 987 1597 2584 4181 6765 10946 Columns 16 through 20 17711 28657 46368 75025 121393 a = 144 233 377 610 987 1597 2584 4181 6765 10946 17711 28657 46368 75025 121393 a = 1597 2584 4181 6765 10946 17711 28657 46368 75025 121393 a = 10946 17711 28657 46368 75025 121393 a = 121393 y = 13 144 1597 10946 121393

4   Pass
n = round(7.^(3:.5:7)); out = [377 987 2584 6765 17711 46368 121393 317811 832040]; assert(isequal(next_fibonacci(n),out));

seq = Columns 1 through 15 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 Columns 16 through 30 987 1597 2584 4181 6765 10946 17711 28657 46368 75025 121393 196418 317811 514229 832040 a = Columns 1 through 15 377 610 987 1597 2584 4181 6765 10946 17711 28657 46368 75025 121393 196418 317811 Columns 16 through 17 514229 832040 a = 987 1597 2584 4181 6765 10946 17711 28657 46368 75025 121393 196418 317811 514229 832040 a = 2584 4181 6765 10946 17711 28657 46368 75025 121393 196418 317811 514229 832040 a = 6765 10946 17711 28657 46368 75025 121393 196418 317811 514229 832040 a = 17711 28657 46368 75025 121393 196418 317811 514229 832040 a = 46368 75025 121393 196418 317811 514229 832040 a = 121393 196418 317811 514229 832040 a = 317811 514229 832040 a = 832040 y = 377 987 2584 6765 17711 46368 121393 317811 832040

Suggested Problems

More from this Author2

Community Treasure Hunt

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

Start Hunting!