Cody

Problem 44481. How many Fibonacci numbers?

Solution 3091171

Submitted on 6 Oct 2020 by Klap Hest
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))

last = 1 y = 1 last = 2 y = 1 last = 3 y = 1 last = 5 y = 2 last = 8 y = 2 last = 13 y = 3 last = 21 y = 4 last = 34 y = 4

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

last = 1 y = 0 last = 2 y = 0 last = 3 y = 0 last = 5 y = 1 last = 8 y = 1 last = 13 y = 1 last = 21 y = 1 last = 34 y = 1 last = 55 y = 2 last = 89 y = 2 last = 144 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))

last = 1 y = 0 last = 2 y = 1 last = 3 y = 2 last = 5 y = 3 last = 8 y = 3 last = 13 y = 3 last = 21 y = 3 last = 34 y = 3 last = 55 y = 3 last = 89 y = 3 last = 144 y = 3 last = 233 y = 3 last = 377 y = 3 last = 610 y = 3 last = 987 y = 3 last = 1597 y = 3 last = 2584 y = 3 last = 4181 y = 3 last = 6765 y = 3 last = 10946 y = 3 last = 17711 y = 3 last = 28657 y = 3 last = 46368 y = 3 last = 75025 y = 3 last = 121393 y = 3 last = 196418 y = 3 last = 317811 y = 3 last = 514229 y = 3 last = 832040 y = 3 last = 1346269 y = 3 last = 2178309 y = 3 last = 3524578 y = 3 last = 5702887 y = 3 last = 9227465 y = 3 last = 14930352 y = 3 last = 24157817 y = 3 last = 39088169 y = 3 last = 63245986 y = 3 last = 102334155 y = 3 last = 165580141 y = 3 last = 267914296 y = 3 last = 433494437 y = 3 last = 701408733 y = 3 last = 1.1349e+09 y = 3 last = 1.8363e+09 y = 3 last = 2.9712e+09 y = 3 last = 4.8075e+09 y = 3 last = 7.7787e+09 y = 3 last = 1.2586e+10 y = 3 last = 2.0365e+10 y = 3 last = 3.2951e+10 y = 3 last = 5.3316e+10 y = 3 last = 8.6268e+10 y = 3 last = 1.3958e+11 y = 3 last = 2.2585e+11 y = 3 last = 3.6544e+11 y = 3 last = 5.9129e+11 y = 3 last = 9.5672e+11 y = 3 last = 1.5480e+12 y = 3 last = 2.5047e+12 y = 3 last = 4.0527e+12 y = 3 last = 6.5575e+12 y = 3 last = 1.0610e+13 y = 3 last = 1.7168e+13 y = 3 last = 2.7778e+13 y = 3 last = 4.4946e+13 y = 3 last = 7.2723e+13 y = 3 last = 1.1767e+14 y = 3 last = 1.9039e+14 y = 3 last = 3.0806e+14 y = 3 last = 4.9845e+14 y = 3 last = 8.0652e+14 y = 3 last = 1.3050e+15 y = 3 last = 2.1115e+15 y = 3 last = 3.4165e+15 y = 3 last = 5.5279e+15 y = 3 last = 8.9444e+15 y = 3 last = 1.4472e+16 y = 3

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))

last = 1 y = 0 last = 2 y = 1 last = 3 y = 2 last = 5 y = 3 last = 8 y = 3 last = 13 y = 3 last = 21 y = 3 last = 34 y = 3 last = 55 y = 3 last = 89 y = 3 last = 144 y = 3 last = 233 y = 3 last = 377 y = 3 last = 610 y = 3 last = 987 y = 3 last = 1597 y = 3 last = 2584 y = 3 last = 4181 y = 3 last = 6765 y = 3 last = 10946 y = 3 last = 17711 y = 3 last = 28657 y = 3 last = 46368 y = 3 last = 75025 y = 3 last = 121393 y = 3 last = 196418 y = 3 last = 317811 y = 3 last = 514229 y = 3 last = 832040 y = 3 last = 1346269 y = 3 last = 2178309 y = 3 last = 3524578 y = 3 last = 5702887 y = 3 last = 9227465 y = 3 last = 14930352 y = 3 last = 24157817 y = 3 last = 39088169 y = 3 last = 63245986 y = 3 last = 102334155 y = 3 last = 165580141 y = 3 last = 267914296 y = 3 last = 433494437 y = 3 last = 701408733 y = 3 last = 1.1349e+09 y = 3 last = 1.8363e+09 y = 3 last = 2.9712e+09 y = 3 last = 4.8075e+09 y = 3 last = 7.7787e+09 y = 3 last = 1.2586e+10 y = 3 last = 2.0365e+10 y = 3 last = 3.2951e+10 y = 3 last = 5.3316e+10 y = 3 last = 8.6268e+10 y = 3 last = 1.3958e+11 y = 3 last = 2.2585e+11 y = 3 last = 3.6544e+11 y = 3 last = 5.9129e+11 y = 3 last = 9.5672e+11 y = 3 last = 1.5480e+12 y = 3 last = 2.5047e+12 y = 3 last = 4.0527e+12 y = 3 last = 6.5575e+12 y = 3 last = 1.0610e+13 y = 3 last = 1.7168e+13 y = 3 last = 2.7778e+13 y = 3 last = 4.4946e+13 y = 3 last = 7.2723e+13 y = 3 last = 1.1767e+14 y = 3 last = 1.9039e+14 y = 3 last = 3.0806e+14 y = 3 last = 4.9845e+14 y = 3 last = 8.0652e+14 y = 3 last = 1.3050e+15 y = 3 last = 2.1115e+15 y = 3 last = 3.4165e+15 y = 3 last = 5.5279e+15 y = 3 last = 8.9444e+15 y = 4 last = 1.4472e+16 y = 4

Suggested Problems

Community Treasure Hunt

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

Start Hunting!