Cody

# Problem 434. Return the Fibonacci Sequence

Solution 510921

Submitted on 9 Oct 2014 by Georges
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(145); assert(isequal(X(end),144) && length(X)==12)

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

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

b = 1 1 2 b = 1 1 2 3 b = 1 1 2 3 5 b = 1 1 2 3 5 8 b = 1 1 2 3 5 8 13 b = 1 1 2 3 5 8 13 21 b = 1 1 2 3 5 8 13 21 34 b = 1 1 2 3 5 8 13 21 34 55 b = 1 1 2 3 5 8 13 21 34 55 89 b = 1 1 2 3 5 8 13 21 34 55 89 144 b = 1 1 2 3 5 8 13 21 34 55 89 144 233 b = 1 1 2 3 5 8 13 21 34 55 89 144 233 377 b = 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 b = 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 b = Columns 1 through 8 1 1 2 3 5 8 13 21 Columns 9 through 16 34 55 89 144 233 377 610 987 Column 17 1597 b = Columns 1 through 8 1 1 2 3 5 8 13 21 Columns 9 through 16 34 55 89 144 233 377 610 987 Columns 17 through 18 1597 2584 b = Columns 1 through 8 1 1 2 3 5 8 13 21 Columns 9 through 16 34 55 89 144 233 377 610 987 Columns 17 through 19 1597 2584 4181 b = Columns 1 through 8 1 1 2 3 5 8 13 21 Columns 9 through 16 34 55 89 144 233 377 610 987 Columns 17 through 20 1597 2584 4181 6765

3   Pass
%% X = fib_seq(987419996); assert(isequal(X(end),701408733) && length(X)==44)

b = 1 1 2 b = 1 1 2 3 b = 1 1 2 3 5 b = 1 1 2 3 5 8 b = 1 1 2 3 5 8 13 b = 1 1 2 3 5 8 13 21 b = 1 1 2 3 5 8 13 21 34 b = 1 1 2 3 5 8 13 21 34 55 b = 1 1 2 3 5 8 13 21 34 55 89 b = 1 1 2 3 5 8 13 21 34 55 89 144 b = 1 1 2 3 5 8 13 21 34 55 89 144 233 b = 1 1 2 3 5 8 13 21 34 55 89 144 233 377 b = 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 b = 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 b = Columns 1 through 8 1 1 2 3 5 8 13 21 Columns 9 through 16 34 55 89 144 233 377 610 987 Column 17 1597 b = Columns 1 through 8 1 1 2 3 5 8 13 21 Columns 9 through 16 34 55 89 144 233 377 610 987 Columns 17 through 18 1597 2584 b = Columns 1 through 8 1 1 2 3 5 8 13 21 Columns 9 through 16 34 55 89 144 233 377 610 987 Columns 17 through 19 1597 2584 4181 b = Columns 1 through 8 1 1 2 3 5 8 13 21 Columns 9 through 16 34 55 89 144 233 377 610 987 Columns 17 through 20 1597 2584 4181 6765 b = Columns 1 through 8 1 1 2 3 5 8 13 21 Columns 9 through 16 34 55 89 144 233 377 610 987 Columns 17 through 21 1597 2584 4181 6765 10946 b = Columns 1 through 8 1 1 2 3 5 8 13 21 Columns 9 through 16 34 55 89 144 233 377 610 987 Columns 17 through 22 1597 2584 4181 6765 10946 17711 b = Columns 1 through 8 1 1 2 3 5 8 13 21 Columns 9 through 16 34 55 89 144 233 377 610 987 Columns 17 through 23 1597 2584 4181 6765 10946 17711 28657 b = Columns 1 through 8 1 1 2 3 5 8 13 21 Columns 9 through 16 34 55 89 144 233 377 610 987 Columns 17 through 24 1597 2584 4181 6765 10946 17711 28657 46368 b = Columns 1 through 8 1 1 2 3 5 8 13 21 Columns 9 through 16 34 55 89 144 233 377 610 987 Columns 17 through 24 1597 2584 4181 6765 10946 17711 28657 46368 Column 25 75025 b = Columns 1 through 8 1 1 2 3 5 8 13 21 Columns 9 through 16 34 55 89 144 233 377 610 987 Columns 17 through 24 1597 2584 4181 6765 10946 17711 28657 46368 Columns 25 through 26 75025 121393 b = Columns 1 through 8 1 1 2 3 5 8 13 21 Columns 9 through 16 34 55 89 144 233 377 610 987 Columns 17 through 24 1597 2584 4181 6765 10946 17711 28657 46368 Columns 25 through 27 75025 121393 196418 b = Columns 1 through 8 1 1 2 3 5 8 13 21 Columns 9 through 16 34 55 89 144 233 377 610 987 Columns 17 through 24 1597 2584 4181 6765 10946 17711 28657 46368 Columns 25 through 28 75025 121393 196418 317811 b = Columns 1 through 8 1 1 2 3 5 8 13 21 Columns 9 through 16 34 55 89 144 233 377 610 987 Columns 17 through 24 1597 2584 4181 6765 10946 17711 28657 46368 Columns 25 through 29 75025 121393 196418 317811 514229 b = Columns 1 through 8 1 1 2 3 5 8 13 21 Columns 9 through 16 34 55 89 144 233 377 610 987 Columns 17 through 24 1597 2584 4181 6765 10946 17711 28657 46368 Columns 25 through 30 75025 121393 196418 317811 514229 832040 b = Columns 1 through 8 1 1 2 3 5 8 13 21 Columns 9 through 16 34 55 89 144 233 377 610 987 Columns 17 through 24 1597 2584 4181 6765 10946 17711 28657 46368 Columns 25 through 31 75025 121393 196418 317811 514229 832040 1346269 b = Columns 1 through 8 1 1 2 3 5 8 13 21 Columns 9 through 16 34 55 89 144 233 377 610 987 Columns 17 through 24 1597 2584 4181 6765 10946 17711 28657 46368 Columns 25 through 32 75025 121393 196418 317811 514229 832040 1346269 2178309 b = Columns 1 through 8 1 1 2 3 5 8 13 21 Columns 9 through 16 34 55 89 144 233 377 610 987 Columns 17 through 24 1597 2584 4181 6765 10946 17711 28657 46368 Columns 25 through 32 75025 121393 196418 317811 514229 832040 1346269 2178309 Column 33 3524578 b = Columns 1 through 8 1 1 2 3 5 8 13 21 Columns 9 through 16 34 55 89 144 233 377 610 987 Columns 17 through 24 1597 2584 4181 6765 10946 17711 28657 46368 Columns 25 through 32 75025 121393 196418 317811 514229 832040 1346269 2178309 Columns 33 through 34 3524578 5702887 b = Columns 1 through 8 1 1 2 3 5 8 13 21 Columns 9 through 16 34 55 89 144 233 377 610 987 Columns 17 through 24 1597 2584 4181 6765 10946 17711 28657 46368 Columns 25 through 32 75025 121393 196418 317811 514229 832040 1346269 2178309 Columns 33 through 35 3524578 5702887 9227465 b = Columns 1 through 8 1 1 2 3 5 8 13 21 Columns 9 through 16 34 55 89 144 233 377 610 987 Columns 17 through 24 1597 2584 4181 6765 10946 17711 28657 46368 Columns 25 through 32 75025 121393 196418 317811 514229 832040 1346269 2178309 Columns 33 through 36 3524578 5702887 9227465 14930352 b = Columns 1 through 8 1 1 2 3 5 8 13 21 Columns 9 through 16 34 55 89 144 233 377 610 987 Columns 17 through 24 1597 2584 4181 6765 10946 17711 28657 46368 Columns 25 through 32 75025 121393 196418 317811 514229 832040 1346269 2178309 Columns 33 through 37 3524578 5702887 9227465 14930352 24157817 b = Columns 1 through 8 1 1 2 3 5 8 13 21 Columns 9 through 16 34 55 89 144 233 377 610 987 Columns 17 through 24 1597 2584 4181 6765 ...

4   Pass
%% X = fib_seq(1134903171); assert(isequal(X(end),1134903170) && length(X)==45)

b = 1 1 2 b = 1 1 2 3 b = 1 1 2 3 5 b = 1 1 2 3 5 8 b = 1 1 2 3 5 8 13 b = 1 1 2 3 5 8 13 21 b = 1 1 2 3 5 8 13 21 34 b = 1 1 2 3 5 8 13 21 34 55 b = 1 1 2 3 5 8 13 21 34 55 89 b = 1 1 2 3 5 8 13 21 34 55 89 144 b = 1 1 2 3 5 8 13 21 34 55 89 144 233 b = 1 1 2 3 5 8 13 21 34 55 89 144 233 377 b = 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 b = 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 b = Columns 1 through 8 1 1 2 3 5 8 13 21 Columns 9 through 16 34 55 89 144 233 377 610 987 Column 17 1597 b = Columns 1 through 8 1 1 2 3 5 8 13 21 Columns 9 through 16 34 55 89 144 233 377 610 987 Columns 17 through 18 1597 2584 b = Columns 1 through 8 1 1 2 3 5 8 13 21 Columns 9 through 16 34 55 89 144 233 377 610 987 Columns 17 through 19 1597 2584 4181 b = Columns 1 through 8 1 1 2 3 5 8 13 21 Columns 9 through 16 34 55 89 144 233 377 610 987 Columns 17 through 20 1597 2584 4181 6765 b = Columns 1 through 8 1 1 2 3 5 8 13 21 Columns 9 through 16 34 55 89 144 233 377 610 987 Columns 17 through 21 1597 2584 4181 6765 10946 b = Columns 1 through 8 1 1 2 3 5 8 13 21 Columns 9 through 16 34 55 89 144 233 377 610 987 Columns 17 through 22 1597 2584 4181 6765 10946 17711 b = Columns 1 through 8 1 1 2 3 5 8 13 21 Columns 9 through 16 34 55 89 144 233 377 610 987 Columns 17 through 23 1597 2584 4181 6765 10946 17711 28657 b = Columns 1 through 8 1 1 2 3 5 8 13 21 Columns 9 through 16 34 55 89 144 233 377 610 987 Columns 17 through 24 1597 2584 4181 6765 10946 17711 28657 46368 b = Columns 1 through 8 1 1 2 3 5 8 13 21 Columns 9 through 16 34 55 89 144 233 377 610 987 Columns 17 through 24 1597 2584 4181 6765 10946 17711 28657 46368 Column 25 75025 b = Columns 1 through 8 1 1 2 3 5 8 13 21 Columns 9 through 16 34 55 89 144 233 377 610 987 Columns 17 through 24 1597 2584 4181 6765 10946 17711 28657 46368 Columns 25 through 26 75025 121393 b = Columns 1 through 8 1 1 2 3 5 8 13 21 Columns 9 through 16 34 55 89 144 233 377 610 987 Columns 17 through 24 1597 2584 4181 6765 10946 17711 28657 46368 Columns 25 through 27 75025 121393 196418 b = Columns 1 through 8 1 1 2 3 5 8 13 21 Columns 9 through 16 34 55 89 144 233 377 610 987 Columns 17 through 24 1597 2584 4181 6765 10946 17711 28657 46368 Columns 25 through 28 75025 121393 196418 317811 b = Columns 1 through 8 1 1 2 3 5 8 13 21 Columns 9 through 16 34 55 89 144 233 377 610 987 Columns 17 through 24 1597 2584 4181 6765 10946 17711 28657 46368 Columns 25 through 29 75025 121393 196418 317811 514229 b = Columns 1 through 8 1 1 2 3 5 8 13 21 Columns 9 through 16 34 55 89 144 233 377 610 987 Columns 17 through 24 1597 2584 4181 6765 10946 17711 28657 46368 Columns 25 through 30 75025 121393 196418 317811 514229 832040 b = Columns 1 through 8 1 1 2 3 5 8 13 21 Columns 9 through 16 34 55 89 144 233 377 610 987 Columns 17 through 24 1597 2584 4181 6765 10946 17711 28657 46368 Columns 25 through 31 75025 121393 196418 317811 514229 832040 1346269 b = Columns 1 through 8 1 1 2 3 5 8 13 21 Columns 9 through 16 34 55 89 144 233 377 610 987 Columns 17 through 24 1597 2584 4181 6765 10946 17711 28657 46368 Columns 25 through 32 75025 121393 196418 317811 514229 832040 1346269 2178309 b = Columns 1 through 8 1 1 2 3 5 8 13 21 Columns 9 through 16 34 55 89 144 233 377 610 987 Columns 17 through 24 1597 2584 4181 6765 10946 17711 28657 46368 Columns 25 through 32 75025 121393 196418 317811 514229 832040 1346269 2178309 Column 33 3524578 b = Columns 1 through 8 1 1 2 3 5 8 13 21 Columns 9 through 16 34 55 89 144 233 377 610 987 Columns 17 through 24 1597 2584 4181 6765 10946 17711 28657 46368 Columns 25 through 32 75025 121393 196418 317811 514229 832040 1346269 2178309 Columns 33 through 34 3524578 5702887 b = Columns 1 through 8 1 1 2 3 5 8 13 21 Columns 9 through 16 34 55 89 144 233 377 610 987 Columns 17 through 24 1597 2584 4181 6765 10946 17711 28657 46368 Columns 25 through 32 75025 121393 196418 317811 514229 832040 1346269 2178309 Columns 33 through 35 3524578 5702887 9227465 b = Columns 1 through 8 1 1 2 3 5 8 13 21 Columns 9 through 16 34 55 89 144 233 377 610 987 Columns 17 through 24 1597 2584 4181 6765 10946 17711 28657 46368 Columns 25 through 32 75025 121393 196418 317811 514229 832040 1346269 2178309 Columns 33 through 36 3524578 5702887 9227465 14930352 b = Columns 1 through 8 1 1 2 3 5 8 13 21 Columns 9 through 16 34 55 89 144 233 377 610 987 Columns 17 through 24 1597 2584 4181 6765 10946 17711 28657 46368 Columns 25 through 32 75025 121393 196418 317811 514229 832040 1346269 2178309 Columns 33 through 37 3524578 5702887 9227465 14930352 24157817 b = Columns 1 through 8 1 1 2 3 5 8 13 21 Columns 9 through 16 34 55 89 144 233 377 610 987 Columns 17 through 24 1597 2584 4181 6765 ...

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

b = 1 1 2 b = 1 1 2 3 b = 1 1 2 3 5 b = 1 1 2 3 5 8 b = 1 1 2 3 5 8 13 b = 1 1 2 3 5 8 13 21 b = 1 1 2 3 5 8 13 21 34 b = 1 1 2 3 5 8 13 21 34 55 b = 1 1 2 3 5 8 13 21 34 55 89 b = 1 1 2 3 5 8 13 21 34 55 89 144 b = 1 1 2 3 5 8 13 21 34 55 89 144 233 b = 1 1 2 3 5 8 13 21 34 55 89 144 233 377 b = 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 b = 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 b = Columns 1 through 8 1 1 2 3 5 8 13 21 Columns 9 through 16 34 55 89 144 233 377 610 987 Column 17 1597 b = Columns 1 through 8 1 1 2 3 5 8 13 21 Columns 9 through 16 34 55 89 144 233 377 610 987 Columns 17 through 18 1597 2584 b = Columns 1 through 8