Cody

# Problem 43016. Find the next Fibonacci number

Solution 2020984

Submitted on 14 Nov 2019 by Jackson Cocks
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));

b = 1 f = 1 1 f = 1 1 2 f = 1 1 2 3 f = 1 1 2 3 5 f = 1 1 2 3 5 8 y = 8

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

b = 3 f = 1 1 f = 1 1 2 f = 1 1 2 3 f = 1 1 2 3 5 f = 1 1 2 3 5 8 f = 1 1 2 3 5 8 13 y = 13 f = 1 1 f = 1 1 2 f = 1 1 2 3 f = 1 1 2 3 5 f = 1 1 2 3 5 8 f = 1 1 2 3 5 8 13 f = 1 1 2 3 5 8 13 21 f = 1 1 2 3 5 8 13 21 34 f = 1 1 2 3 5 8 13 21 34 55 y = 13 55 f = 1 1 f = 1 1 2 f = 1 1 2 3 f = 1 1 2 3 5 f = 1 1 2 3 5 8 f = 1 1 2 3 5 8 13 f = 1 1 2 3 5 8 13 21 f = 1 1 2 3 5 8 13 21 34 f = 1 1 2 3 5 8 13 21 34 55 y = 13 55 55

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

b = 5 f = 1 1 f = 1 1 2 f = 1 1 2 3 f = 1 1 2 3 5 f = 1 1 2 3 5 8 f = 1 1 2 3 5 8 13 y = 13 f = 1 1 f = 1 1 2 f = 1 1 2 3 f = 1 1 2 3 5 f = 1 1 2 3 5 8 f = 1 1 2 3 5 8 13 f = 1 1 2 3 5 8 13 21 f = 1 1 2 3 5 8 13 21 34 f = 1 1 2 3 5 8 13 21 34 55 f = 1 1 2 3 5 8 13 21 34 55 89 f = 1 1 2 3 5 8 13 21 34 55 89 144 y = 13 144 f = 1 1 f = 1 1 2 f = 1 1 2 3 f = 1 1 2 3 5 f = 1 1 2 3 5 8 f = 1 1 2 3 5 8 13 f = 1 1 2 3 5 8 13 21 f = 1 1 2 3 5 8 13 21 34 f = 1 1 2 3 5 8 13 21 34 55 f = 1 1 2 3 5 8 13 21 34 55 89 f = 1 1 2 3 5 8 13 21 34 55 89 144 f = 1 1 2 3 5 8 13 21 34 55 89 144 233 f = 1 1 2 3 5 8 13 21 34 55 89 144 233 377 f = 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 f = 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 f = Columns 1 through 15 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 Columns 16 through 17 987 1597 y = 13 144 1597 f = 1 1 f = 1 1 2 f = 1 1 2 3 f = 1 1 2 3 5 f = 1 1 2 3 5 8 f = 1 1 2 3 5 8 13 f = 1 1 2 3 5 8 13 21 f = 1 1 2 3 5 8 13 21 34 f = 1 1 2 3 5 8 13 21 34 55 f = 1 1 2 3 5 8 13 21 34 55 89 f = 1 1 2 3 5 8 13 21 34 55 89 144 f = 1 1 2 3 5 8 13 21 34 55 89 144 233 f = 1 1 2 3 5 8 13 21 34 55 89 144 233 377 f = 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 f = 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 f = Columns 1 through 15 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 Columns 16 through 17 987 1597 f = Columns 1 through 15 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 Columns 16 through 18 987 1597 2584 f = Columns 1 through 15 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 Columns 16 through 19 987 1597 2584 4181 f = Columns 1 through 15 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 Columns 16 through 20 987 1597 2584 4181 6765 f = Columns 1 through 15 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 Columns 16 through 21 987 1597 2584 4181 6765 10946 y = 13 144 1597 10946 f = 1 1 f = 1 1 2 f = 1 1 2 3 f = 1 1 2 3 5 f = 1 1 2 3 5 8 f = 1 1 2 3 5 8 13 f = 1 1 2 3 5 8 13 21 f = 1 1 2 3 5 8 13 21 34 f = 1 1 2 3 5 8 13 21 34 55 f = 1 1 2 3 5 8 13 21 34 55 89 f = 1 1 2 3 5 8 13 21 34 55 89 144 f = 1 1 2 3 5 8 13 21 34 55 89 144 233 f = 1 1 2 3 5 8 13 21 34 55 89 144 233 377 f = 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 f = 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 f = Columns 1 through 15 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 Columns 16 through 17 987 1597 f = Columns 1 through 15 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 Columns 16 through 18 987 1597 2584 f = Columns 1 through 15 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 Columns 16 through 19 987 1597 2584 4181 f = Columns 1 through 15 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 Columns 16 through 20 987 1597 2584 4181 6765 f = Columns 1 through 15 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 Columns 16 through 21 987 1597 2584 4181 6765 10946 f = Columns 1 through 15 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 Columns 16 through 22 987 1597 2584 4181 6765 10946 17711 f = Columns 1 through 15 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 Columns 16 through 23 987 1597 2584 4181 6765 10946 17711 28657 f = Columns 1 through 15 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 Columns 16 through 24 987 1597 2584 4181 6765 10946 17711 28657 46368 f = Columns 1 through 15 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 Columns 16 through 25 987 1597 2584 4181 6765 10946 17711 28657 46368 75025 f = 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 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));

b = 9 f = 1 1 f = 1 1 2 f = 1 1 2 3 f = 1 1 2 3 5 f = 1 1 2 3 5 8 f = 1 1 2 3 5 8 13 f = 1 1 2 3 5 8 13 21 f = 1 1 2 3 5 8 13 21 34 f = 1 1 2 3 5 8 13 21 34 55 f = 1 1 2 3 5 8 13 21 34 55 89 f = 1 1 2 3 5 8 13 21 34 55 89 144 f = 1 1 2 3 5 8 13 21 34 55 89 144 233 f = 1 1 2 3 5 8 13 21 34 55 89 144 233 377 y = 377 f = 1 1 f = 1 1 2 f = 1 1 2 3 f = 1 1 2 3 5 f = 1 1 2 3 5 8 f = 1 1 2 3 5 8 13 f = 1 1 2 3 5 8 13 21 f = 1 1 2 3 5 8 13 21 34 f = 1 1 2 3 5 8 13 21 34 55 f = 1 1 2 3 5 8 13 21 34 55 89 f = 1 1 2 3 5 8 13 21 34 55 89 144 f = 1 1 2 3 5 8 13 21 34 55 89 144 233 f = 1 1 2 3 5 8 13 21 34 55 89 144 233 377 f = 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 f = 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 y = 377 987 f = 1 1 f = 1 1 2 f = 1 1 2 3 f = 1 1 2 3 5 f = 1 1 2 3 5 8 f = 1 1 2 3 5 8 13 f = 1 1 2 3 5 8 13 21 f = 1 1 2 3 5 8 13 21 34 f = 1 1 2 3 5 8 13 21 34 55 f = 1 1 2 3 5 8 13 21 34 55 89 f = 1 1 2 3 5 8 13 21 34 55 89 144 f = 1 1 2 3 5 8 13 21 34 55 89 144 233 f = 1 1 2 3 5 8 13 21 34 55 89 144 233 377 f = 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 f = 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 f = Columns 1 through 15 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 Columns 16 through 17 987 1597 f = Columns 1 through 15 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 Columns 16 through 18 987 1597 2584 y = 377 987 2584 f = 1 1 f = 1 1 2 f = 1 1 2 3 f = 1 1 2 3 5 f = 1 1 2 3 5 8 f = 1 1 2 3 5 8 13 f = 1 1 2 3 5 8 13 21 f = 1 1 2 3 5 8 13 21 34 f = 1 1 2 3 5 8 13 21 34 55 f = 1 1 2 3 5 8 13 21 34 55 89 f = 1 1 2 3 5 8 13 21 34 55 89 144 f = 1 1 2 3 5 8 13 21 34 55 89 144 233 f = 1 1 2 3 5 8 13 21 34 55 89 144 233 377 f = 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 f = 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 f = Columns 1 through 15 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 Columns 16 through 17 987 1597 f = Columns 1 through 15 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 Columns 16 through 18 987 1597 2584 f = Columns 1 through 15 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 Columns 16 through 19 987 1597 2584 4181 f = Columns 1 through 15 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 Columns 16 through 20 987 1597 2584 4181 6765 y = 377 987 2584 6765 f = 1 1 f = 1 1 2 f = 1 1 2 3 f = 1 1 2 3 5 f = 1 1 2 3 5 8 f = 1 1 2 3 5 8 13 f = 1 1 2 3 5 8 13 21 f = 1 1 2 3 5 8 13 21 34 f = 1 1 2 3 5 8 13 21 34 55 f = 1 1 2 3 5 8 13 21 34 55 89 f = 1 1 2 3 5 8 13 21 34 55 89 144 f = 1 1 2 3 5 8 13 21 34 55 89 144 233 f = 1 1 2 3 5 8 13 21 34 55 89 144 233 377 f = 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 f = 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 f = Columns 1 through 15 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 Columns 16 through 17 987 1597 f = Columns 1 through 15 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 Columns 16 through 18 987 1597 2584 f = Columns 1 through 15 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 Columns 16 through 19 987 1597 2584 4181 f = Columns 1 through 15 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 Columns 16 through 20 987 1597 2584 4181 6765 f = Columns 1 through 15 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 Columns 16 through 21 987 1597 2584 4181 6765 10946 f = Columns 1 through 15 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 Columns 16 through 22 987 1597 2584 4181 6765 10946 17711 y = 377 987 2584 6765 17711 f = 1 1 f = 1 1 2 f = 1 1 2 3 f = 1 1 2 3 5 f = 1 1 2 3 5 8 f = 1 1 2 3 5 8 13 f = 1 1 2 3 5 8 13 21 f = 1 1 2 3 5 8 13 21 34 f = 1 1 2 3 5 8 13 21 34 55 f = 1 1 2 3 5 8 13 21 34 55 89 f = 1 1 2 3 5 8 13 21 34 55 89 144 f = 1 1 2 3 5 8 13 21 34 55 89 144 233 f = 1 1 2 3 5 8 13 21 34 55 89 144 233 377 f = 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 f = 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 f = Columns 1 through 15 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 Columns 16 through 17 987 1597 f = Columns 1 through 15 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 Columns 16 through 18 987 1597 2584 f = Columns 1 through 15 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 Columns 16 through 19 987 1597 2584 4181 f = Columns 1 through 15 1 1 2 3 5 8 13 21 34 55 89...