Cody

# Problem 434. Return the Fibonacci Sequence

Solution 3825798

Submitted on 24 Nov 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   Pass
X = fib_seq(34); assert(isequal(X(end),21) && length(X)==8)

y = 1 1 2 3 5 8 13 21

2   Pass
X = fib_seq(35); assert(isequal(X(end),34) && length(X)==9)

y = 1 1 2 3 5 8 13 21 34

3   Pass
X = fib_seq(145); assert(isequal(X(end),144) && length(X)==12)

y = 1 1 2 3 5 8 13 21 34 55 89 144

4   Pass
X = fib_seq(4196); assert(isequal(X(end),4181) && length(X)==19)

y = Columns 1 through 14 1 1 2 3 5 8 13 21 34 55 89 144 233 377 Columns 15 through 19 610 987 1597 2584 4181

5   Fail
X = fib_seq(987419996); assert(isequal(X(end),701408733) && length(X)==44)

Out of memory. Error in fib_seq (line 2) y = zeros(1,N); Error in Test5 (line 1) X = fib_seq(987419996);

6   Fail
X = fib_seq(1134903171); assert(isequal(X(end),1134903170) && length(X)==45)

Out of memory. Error in fib_seq (line 2) y = zeros(1,N); Error in Test6 (line 1) X = fib_seq(1134903171);

7   Fail
X = fib_seq(98691443031971); assert(isequal(X(end),72723460248141) && length(X)==68)

Error using zeros Requested 1x98691443031971 (735308.6GB) array exceeds maximum array size preference. Creation of arrays greater than this limit may take a long time and cause MATLAB to become unresponsive. Error in fib_seq (line 2) y = zeros(1,N); Error in Test7 (line 1) X = fib_seq(98691443031971);

### Community Treasure Hunt

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

Start Hunting!