Cody

Solution 2272753

Submitted on 12 May 2020 by Borja21091
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
x1 = 1; x2 = 25; [p,d] = pentagonal_numbers(x1,x2) assert(isequal(p,[1,5,12,22])) assert(isequal(d,[0,1,0,0]))

r1 = 1.0000 -0.6667 r2 = 4.2526 -3.9192 n = 1 2 3 4 p = 1 5 12 22 d = 1×4 logical array 0 1 0 0

2   Pass
x1 = 1; x2 = 4; [p,d] = pentagonal_numbers(x1,x2) assert(isequal(p,1)) assert(isequal(d,0))

r1 = 1.0000 -0.6667 r2 = 1.8081 -1.4748 n = 1 p = 1 d = logical 0

3   Pass
x1 = 10; x2 = 40; [p,d] = pentagonal_numbers(x1,x2) assert(isequal(p,[12,22,35])) assert(isequal(d,[0,0,1]))

r1 = 2.7540 -2.4207 r2 = 5.3333 -5.0000 n = 3 4 5 p = 12 22 35 d = 1×3 logical array 0 0 1

4   Pass
x1 = 10; x2 = 99; [p,d] = pentagonal_numbers(x1,x2) assert(isequal(p,[12,22,35,51,70,92])) assert(isequal(d,[0,0,1,0,1,0]))

r1 = 2.7540 -2.4207 r2 = 8.2924 -7.9591 n = 3 4 5 6 7 8 p = 12 22 35 51 70 92 d = 1×6 logical array 0 0 1 0 1 0

5   Pass
x1 = 100; x2 = 999; [p,d] = pentagonal_numbers(x1,x2) assert(isequal(p,[117,145,176,210,247,287,330,376,425,477,532,590,651,715,782,852,925])) assert(isequal(d,[0,1,0,1,0,0,1,0,1,0,0,1,0,1,0,0,1]))

r1 = 8.3333 -8.0000 r2 = 25.9742 -25.6408 n = 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 p = 117 145 176 210 247 287 330 376 425 477 532 590 651 715 782 852 925 d = 1×17 logical array 0 1 0 1 0 0 1 0 1 0 0 1 0 1 0 0 1

6   Pass
x1 = 40; x2 = 50; [p,d] = pentagonal_numbers(x1,x2) assert(isempty(p)) assert(isempty(d))

r1 = 5.3333 -5.0000 r2 = 5.9426 -5.6092 n = 1×0 empty double row vector p = 1×0 empty double row vector d = 1×0 empty logical array

7   Pass
x1 = 1000; x2 = 1500; [p,d] = pentagonal_numbers(x1,x2) assert(isequal(p,[1001,1080,1162,1247,1335,1426])) assert(isequal(d,[0,1,0,0,1,0]))

r1 = 25.9871 -25.6538 r2 = 31.7899 -31.4565 n = 26 27 28 29 30 31 p = 1001 1080 1162 1247 1335 1426 d = 1×6 logical array 0 1 0 0 1 0

8   Pass
x1 = 1500; x2 = 3000; [p,d] = pentagonal_numbers(x1,x2) assert(isequal(p,[1520,1617,1717,1820,1926,2035,2147,2262,2380,2501,2625,2752,2882])) assert(isequal(d,[1,0,0,1,0,1,0,0,1,0,1,0,0]))

r1 = 31.7899 -31.4565 r2 = 44.8883 -44.5550 n = 32 33 34 35 36 37 38 39 40 41 42 43 44 p = 1520 1617 1717 1820 1926 2035 2147 2262 2380 2501 2625 2752 2882 d = 1×13 logical array 1 0 0 1 0 1 0 0 1 0 1 0 0

9   Pass
x1 = 1; x2 = 3000; [p,d] = pentagonal_numbers(x1,x2) assert(isequal(p,[1,5,12,22,35,51,70,92,117,145,176,210,247,287,330,376,425,477,532,590,651,715,782,852,925,1001,1080,1162,1247,1335,1426,1520,1617,1717,1820,1926,2035,2147,2262,2380,2501,2625,2752,2882])) assert(isequal(d,[0,1,0,0,1,0,1,0,0,1,0,1,0,0,1,0,1,0,0,1,0,1,0,0,1,0,1,0,0,1,0,1,0,0,1,0,1,0,0,1,0,1,0,0]))

r1 = 1.0000 -0.6667 r2 = 44.8883 -44.5550 n = Columns 1 through 30 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 Columns 31 through 44 31 32 33 34 35 36 37 38 39 40 41 42 43 44 p = Columns 1 through 15 1 5 12 22 35 51 70 92 117 145 176 210 247 287 330 Columns 16 through 30 376 425 477 532 590 651 715 782 852 925 1001 1080 1162 1247 1335 Columns 31 through 44 1426 1520 1617 1717 1820 1926 2035 2147 2262 2380 2501 2625 2752 2882 d = 1×44 logical array 0 1 0 0 1 0 1 0 0 1 0 1 0 0 1 0 1 0 0 1 0 1 0 0 1 0 1 0 0 1 0 1 0 0 1 0 1 0 0 1 0 1 0 0

10   Pass
x1 = 10000; x2 = 12000; [p,d] = pentagonal_numbers(x1,x2) assert(isequal(p,[10045,10292,10542,10795,11051,11310,11572,11837])) assert(isequal(d,[1,0,0,1,0,1,0,0]))

r1 = 81.8165 -81.4832 r2 = 89.6095 -89.2762 n = 82 83 84 85 86 87 88 89 p = 10045 10292 10542 10795 11051 11310 11572 11837 d = 1×8 logical array 1 0 0 1 0 1 0 0

11   Pass
x1 = 100000; x2 = 110000; [p,d] = pentagonal_numbers(x1,x2) assert(isequal(p,[100492,101270,102051,102835,103622,104412,105205,106001,106800,107602,108407,109215])) assert(isequal(d,[0,1,0,1,0,0,1,0,1,0,0,1]))

r1 = 258.3656 -258.0323 r2 = 270.9680 -270.6347 n = 259 260 261 262 263 264 265 266 267 268 269 270 p = 100492 101270 102051 102835 103622 104412 105205 106001 106800 107602 108407 109215 d = 1×12 logical array 0 1 0 1 0 0 1 0 1 0 0 1

12   Pass
x1 = 1000000; x2 = 1010101; [p,d] = pentagonal_numbers(x1,x2) assert(isequal(p,[1000825,1003277,1005732,1008190])) assert(isequal(d,[1,0,0,1]))

r1 = 816.6633 -816.3299 r2 = 820.7766 -820.4433 n = 817 818 819 820 p = 1000825 1003277 1005732 1008190 d = 1×4 logical array 1 0 0 1