Cody

# Problem 434. Return the Fibonacci Sequence

Solution 55061

Submitted on 2 Mar 2012 by @bmtran (Bryant Tran)
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)

y = 2 1 1 y = 3 2 1 1 y = 5 3 2 1 1 y = 8 5 3 2 1 1 y = 13 8 5 3 2 1 1 y = 21 13 8 5 3 2 1 1 y = 34 21 13 8 5 3 2 1 1 y = 55 34 21 13 8 5 3 2 1 1 y = Columns 1 through 10 89 55 34 21 13 8 5 3 2 1 Column 11 1 y = Columns 1 through 10 144 89 55 34 21 13 8 5 3 2 Columns 11 through 12 1 1

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

y = 2 1 1 y = 3 2 1 1 y = 5 3 2 1 1 y = 8 5 3 2 1 1 y = 13 8 5 3 2 1 1 y = 21 13 8 5 3 2 1 1 y = 34 21 13 8 5 3 2 1 1 y = 55 34 21 13 8 5 3 2 1 1 y = Columns 1 through 10 89 55 34 21 13 8 5 3 2 1 Column 11 1 y = Columns 1 through 10 144 89 55 34 21 13 8 5 3 2 Columns 11 through 12 1 1 y = Columns 1 through 10 233 144 89 55 34 21 13 8 5 3 Columns 11 through 13 2 1 1 y = Columns 1 through 10 377 233 144 89 55 34 21 13 8 5 Columns 11 through 14 3 2 1 1 y = Columns 1 through 10 610 377 233 144 89 55 34 21 13 8 Columns 11 through 15 5 3 2 1 1 y = Columns 1 through 10 987 610 377 233 144 89 55 34 21 13 Columns 11 through 16 8 5 3 2 1 1 y = Columns 1 through 5 1597 987 610 377 233 Columns 6 through 10 144 89 55 34 21 Columns 11 through 15 13 8 5 3 2 Columns 16 through 17 1 1 y = Columns 1 through 5 2584 1597 987 610 377 Columns 6 through 10 233 144 89 55 34 Columns 11 through 15 21 13 8 5 3 Columns 16 through 18 2 1 1 y = Columns 1 through 5 4181 2584 1597 987 610 Columns 6 through 10 377 233 144 89 55 Columns 11 through 15 34 21 13 8 5 Columns 16 through 19 3 2 1 1

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

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

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

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

5   Fail