Cody

# Problem 44481. How many Fibonacci numbers?

Solution 2180104

Submitted on 28 Mar 2020 by Ahmed Abdelbasit
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 = [1 4 5 7 10 11 13 20 21 23 29]; y_correct = 4; assert(isequal(fib_count(x),y_correct))

value = 29 n = 1 2 3 n = 1 2 3 5 n = 1 2 3 5 8 n = 1 2 3 5 8 13 n = 1 2 3 5 8 13 21 y = 1 y = 1 y = 2 y = 2 y = 2 y = 2 y = 3 y = 3 y = 4 y = 4 y = 4

2   Pass
x = 5:5:100; y_correct = 2; assert(isequal(fib_count(x),y_correct))

value = 100 n = 1 2 3 n = 1 2 3 5 n = 1 2 3 5 8 n = 1 2 3 5 8 13 n = 1 2 3 5 8 13 21 n = 1 2 3 5 8 13 21 34 n = 1 2 3 5 8 13 21 34 55 n = 1 2 3 5 8 13 21 34 55 89 y = 1 y = 1 y = 1 y = 1 y = 1 y = 1 y = 1 y = 1 y = 1 y = 1 y = 2 y = 2 y = 2 y = 2 y = 2 y = 2 y = 2 y = 2 y = 2 y = 2

3   Pass
%x = [2 2 3 3 3 3 3 3 5 5 6 6 6 7 86168291600238450732788312165664788095941068326060883324529903470149056115823592713458328176574447204501]; % Changed the test suite to a number that can be represented as an integer in DOUBLE x = [2 2 3 3 3 3 3 3 5 5 6 6 6 7 8944394323791465]; y_correct = 3; assert(isequal(fib_count(x),y_correct))

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

4   Pass
x = [2 2 3 3 3 3 3 3 5 5 6 6 6 7 8944394323791464]; y_correct = 4; assert(isequal(fib_count(x),y_correct))

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

### Community Treasure Hunt

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

Start Hunting!