Cody

# Problem 434. Return the Fibonacci Sequence

Solution 55732

Submitted on 3 Mar 2012 by Alan Chalker
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)

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

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

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

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

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

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

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

5   Fail

### Community Treasure Hunt

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

Start Hunting!