Cody

# Problem 43016. Find the next Fibonacci number

Solution 2798257

Submitted on 6 Aug 2020
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   Fail
n = 6; out = 8; assert(isequal(next_fibonacci(n),out));

y = 8 i = 2

Index exceeds the number of array elements (1). Error in next_fibonacci (line 5) y = [y,nextfib(x(i))] Error in Test1 (line 3) assert(isequal(next_fibonacci(n),out));

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

y = 13 i = 2 y = 13 55 i = 3 y = 13 55 55 i = 4

Index exceeds the number of array elements (3). Error in next_fibonacci (line 5) y = [y,nextfib(x(i))] Error in Test2 (line 3) assert(isequal(next_fibonacci(n),out));

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

y = 13 i = 2 y = 13 144 i = 3 y = 13 144 1597 i = 4 y = 13 144 1597 10946 i = 5 y = 13 144 1597 10946 121393 i = 6

Index exceeds the number of array elements (5). Error in next_fibonacci (line 5) y = [y,nextfib(x(i))] Error in Test3 (line 3) assert(isequal(next_fibonacci(n),out));

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

y = 377 i = 2 y = 377 987 i = 3 y = 377 987 2584 i = 4 y = 377 987 2584 6765 i = 5 y = 377 987 2584 6765 17711 i = 6 y = 377 987 2584 6765 17711 46368 i = 7 y = 377 987 2584 6765 17711 46368 121393 i = 8 y = 377 987 2584 6765 17711 46368 121393 317811 i = 9 y = 377 987 2584 6765 17711 46368 121393 317811 832040 i = 10

Index exceeds the number of array elements (9). Error in next_fibonacci (line 5) y = [y,nextfib(x(i))] Error in Test4 (line 3) assert(isequal(next_fibonacci(n),out));