Cody

Solution 1999688

Submitted on 2 Nov 2019 by Doan Quang Manh
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]))

a = 1 p = 1 n = 2 a = 5 p = 1 5 n = 3 a = 12 p = 1 5 12 n = 4 a = 22 p = 1 5 12 22 n = 5 a = 35 p = 1 5 12 22 35 n = 6 p = 1 5 12 22 d = 1×4 logical array 0 1 0 0 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))

a = 1 p = 1 n = 2 a = 5 p = 1 5 n = 3 p = 1 d = logical 0 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]))

a = 1 p = 1 n = 2 a = 5 p = 1 5 n = 3 a = 12 p = 1 5 12 n = 4 a = 22 p = 1 5 12 22 n = 5 a = 35 p = 1 5 12 22 35 n = 6 a = 51 p = 1 5 12 22 35 51 n = 7 p = 12 22 35 d = 1×3 logical array 0 0 1 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]))

a = 1 p = 1 n = 2 a = 5 p = 1 5 n = 3 a = 12 p = 1 5 12 n = 4 a = 22 p = 1 5 12 22 n = 5 a = 35 p = 1 5 12 22 35 n = 6 a = 51 p = 1 5 12 22 35 51 n = 7 a = 70 p = 1 5 12 22 35 51 70 n = 8 a = 92 p = 1 5 12 22 35 51 70 92 n = 9 a = 117 p = 1 5 12 22 35 51 70 92 117 n = 10 p = 12 22 35 51 70 92 d = 1×6 logical array 0 0 1 0 1 0 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]))

a = 1 p = 1 n = 2 a = 5 p = 1 5 n = 3 a = 12 p = 1 5 12 n = 4 a = 22 p = 1 5 12 22 n = 5 a = 35 p = 1 5 12 22 35 n = 6 a = 51 p = 1 5 12 22 35 51 n = 7 a = 70 p = 1 5 12 22 35 51 70 n = 8 a = 92 p = 1 5 12 22 35 51 70 92 n = 9 a = 117 p = 1 5 12 22 35 51 70 92 117 n = 10 a = 145 p = 1 5 12 22 35 51 70 92 117 145 n = 11 a = 176 p = 1 5 12 22 35 51 70 92 117 145 176 n = 12 a = 210 p = 1 5 12 22 35 51 70 92 117 145 176 210 n = 13 a = 247 p = 1 5 12 22 35 51 70 92 117 145 176 210 247 n = 14 a = 287 p = 1 5 12 22 35 51 70 92 117 145 176 210 247 287 n = 15 a = 330 p = 1 5 12 22 35 51 70 92 117 145 176 210 247 287 330 n = 16 a = 376 p = 1 5 12 22 35 51 70 92 117 145 176 210 247 287 330 376 n = 17 a = 425 p = 1 5 12 22 35 51 70 92 117 145 176 210 247 287 330 376 425 n = 18 a = 477 p = 1 5 12 22 35 51 70 92 117 145 176 210 247 287 330 376 425 477 n = 19 a = 532 p = 1 5 12 22 35 51 70 92 117 145 176 210 247 287 330 376 425 477 532 n = 20 a = 590 p = 1 5 12 22 35 51 70 92 117 145 176 210 247 287 330 376 425 477 532 590 n = 21 a = 651 p = 1 5 12 22 35 51 70 92 117 145 176 210 247 287 330 376 425 477 532 590 651 n = 22 a = 715 p = 1 5 12 22 35 51 70 92 117 145 176 210 247 287 330 376 425 477 532 590 651 715 n = 23 a = 782 p = 1 5 12 22 35 51 70 92 117 145 176 210 247 287 330 376 425 477 532 590 651 715 782 n = 24 a = 852 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 n = 25 a = 925 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 n = 26 a = 1001 p = Columns 1 through 14 1 5 12 22 35 51 70 92 117 145 176 210 247 287 Columns 15 through 26 330 376 425 477 532 590 651 715 782 852 925 1001 n = 27 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 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))

a = 1 p = 1 n = 2 a = 5 p = 1 5 n = 3 a = 12 p = 1 5 12 n = 4 a = 22 p = 1 5 12 22 n = 5 a = 35 p = 1 5 12 22 35 n = 6 a = 51 p = 1 5 12 22 35 51 n = 7 p = 1×0 empty double row vector d = 1×0 empty logical array 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]))

a = 1 p = 1 n = 2 a = 5 p = 1 5 n = 3 a = 12 p = 1 5 12 n = 4 a = 22 p = 1 5 12 22 n = 5 a = 35 p = 1 5 12 22 35 n = 6 a = 51 p = 1 5 12 22 35 51 n = 7 a = 70 p = 1 5 12 22 35 51 70 n = 8 a = 92 p = 1 5 12 22 35 51 70 92 n = 9 a = 117 p = 1 5 12 22 35 51 70 92 117 n = 10 a = 145 p = 1 5 12 22 35 51 70 92 117 145 n = 11 a = 176 p = 1 5 12 22 35 51 70 92 117 145 176 n = 12 a = 210 p = 1 5 12 22 35 51 70 92 117 145 176 210 n = 13 a = 247 p = 1 5 12 22 35 51 70 92 117 145 176 210 247 n = 14 a = 287 p = 1 5 12 22 35 51 70 92 117 145 176 210 247 287 n = 15 a = 330 p = 1 5 12 22 35 51 70 92 117 145 176 210 247 287 330 n = 16 a = 376 p = 1 5 12 22 35 51 70 92 117 145 176 210 247 287 330 376 n = 17 a = 425 p = 1 5 12 22 35 51 70 92 117 145 176 210 247 287 330 376 425 n = 18 a = 477 p = 1 5 12 22 35 51 70 92 117 145 176 210 247 287 330 376 425 477 n = 19 a = 532 p = 1 5 12 22 35 51 70 92 117 145 176 210 247 287 330 376 425 477 532 n = 20 a = 590 p = 1 5 12 22 35 51 70 92 117 145 176 210 247 287 330 376 425 477 532 590 n = 21 a = 651 p = 1 5 12 22 35 51 70 92 117 145 176 210 247 287 330 376 425 477 532 590 651 n = 22 a = 715 p = 1 5 12 22 35 51 70 92 117 145 176 210 247 287 330 376 425 477 532 590 651 715 n = 23 a = 782 p = 1 5 12 22 35 51 70 92 117 145 176 210 247 287 330 376 425 477 532 590 651 715 782 n = 24 a = 852 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 n = 25 a = 925 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 n = 26 a = 1001 p = Columns 1 through 14 1 5 12 22 35 51 70 92 117 145 176 210 247 287 Columns 15 through 26 330 376 425 477 532 590 651 715 782 852 925 1001 n = 27 a = 1080 p = Columns 1 through 14 1 5 12 22 35 51 70 92 117 145 176 210 247 287 Columns 15 through 27 330 376 425 477 532 590 651 715 782 852 925 1001 1080 n = 28 a = 1162 p = Columns 1 through 14 1 5 12 22 35 51 70 92 117 145 176 210 247 287 Columns 15 through 28 330 376 425 477 532 590 651 715 782 852 925 1001 1080 1162 n = 29 a = 1247 p = Columns 1 through 14 1 5 12 22 35 51 70 92 117 145 176 210 247 287 Columns 15 through 28 330 376 425 477 532 590 651 715 782 852 925 1001 1080 1162 Column 29 1247 n = 30 a = 1335 p = Columns 1 through 14 1 5 12 22 35 51 70 92 117 145 176 210 247 287 Columns 15 through 28 330 376 425 477 532 590 651 715 782 852 925 1001 1080 1162 Columns 29 through 30 1247 1335 n = 31 a = 1426 p = Columns 1 through 14 1 5 12 22 35 51 70 92 117 145 176 210 247 287 Columns 15 through 28 330 376 425 477 532 590 651 715 782 852 925 1001 1080 1162 Columns 29 through 31 1247 1335 1426 n = 32 a = 1520 p = Columns 1 through 14 1 5 12 22 35 51 70 92 117 145 176 210 247 287 Columns 15 through 28 330 376 425 477 532 590 651 715 782 852 925 1001 1080 1162 Columns 29 through 32 1247 1335 1426 1520 n = 33 p = 1001 1080 1162 1247 1335 1426 d = 1×6 logical array 0 1 0 0 1 0 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]))

a = 1 p = 1 n = 2 a = 5 p = 1 5 n = 3 a = 12 p = 1 5 12 n = 4 a = 22 p = 1 5 12 22 n = 5 a = 35 p = 1 5 12 22 35 n = 6 a = 51 p = 1 5 12 22 35 51 n = 7 a = 70 p = 1 5 12 22 35 51 70 n = 8 a = 92 p = 1 5 12 22 35 51 70 92 n = 9 a = 117 p = 1 5 12 22 35 51 70 92 117 n = 10 a = 145 p = 1 5 12 22 35 51 70 92 117 145 n = 11 a = 176 p = 1 5 12 22 35 51 70 92 117 145 176 n = 12 a = 210 p = 1 5 12 22 35 51 70 92 117 145 176 210 n = 13 a = 247 p = 1 5 12 22 35 51 70 92 117 145 176 210 247 n = 14 a = 287 p = 1 5 12 22 35 51 70 92 117 145 176 210 247 287 n = 15 a = 330 p = 1 5 12 22 35 51 70 92 117 145 176 210 247 287 330 n = 16 a = 376 p = 1 5 12 22 35 51 70 92 117 145 176 210 247 287 330 376 n = 17 a = 425 p = 1 5 12 22 35 51 70 92 117 145 176 210 247 287 330 376 425 n = 18 a = 477 p = 1 5 12 22 35 51 70 92 117 145 176 210 247 287 330 376 425 477 n = 19 a = 532 p = 1 5 12 22 35 51 70 92 117 145 176 210 247 287 330 376 425 477 532 n = 20 a = 590 p = 1 5 12 22 35 51 70 92 117 145 176 210 247 287 330 376 425 477 532 590 n = 21 a = 651 p = 1 5 12 22 35 51 70 92 117 145 176 210 247 287 330 376 425 477 532 590 651 n = 22 a = 715 p = 1 5 12 22 35 51 70 92 117 145 176 210 247 287 330 376 425 477 532 590 651 715 n = 23 a = 782 p = 1 5 12 22 35 51 70 92 117 145 176 210 247 287 330 376 425 477 532 590 651 715 782 n = 24 a = 852 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 n = 25 a = 925 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 n = 26 a = 1001 p = Columns 1 through 14 1 5 12 22 35 51 70 92 117 145 176 210 247 287 Columns 15 through 26 330 376 425 477 532 590 651 715 782 852 925 1001 n = 27 a = 1080 p = Columns 1 through 14 1 5 12 22 35 51 70 92 117 145 176 210 247 287 Columns 15 through 27 330 376 425 477 532 590 651 715 782 852 925 1001 1080 n = 28 a = 1162 p = Columns 1 through 14 1 5 12 22 35 51 70 92 117 145 176 210 247 287 Columns 15 through 28 330 376 425 477 532 590 651 715 782 852 925 1001 1080 1162 n = 29 a = 1247 p = Columns 1 through 14 1 5 12 22 35 51 70 92 117 145 176 210 247 287 Columns 15 through 28 330 376 425 477 532 590 651 715 782 852 925 1001 1080 1162 Column 29 1247 n = 30 a = 1335 p = Columns 1 through 14 1 5 12 22 35 51 70 92 117 145 176 210 247 287 Columns 15 through 28 330 376 425 477 532 590 651 715 782 852 925 1001 1080 1162 Columns 29 through 30 1247 1335 n = 31 a = 1426 p = Columns 1 through 14 1 5 12 22 35 51 70 92 117 145 176 210 247 287 Columns 15 through 28 330 376 425 477 532 590 651 715 782 852 925 1001 1080 1162 Columns 29 through 31 1247 1335 1426 n = 32 a = 1520 p = Columns 1 through 14 1 5 12 22 35 51 70 92 117 145 176 210 247 287 Columns 15 through 28 330 376 425 477 532 590 651 715 782 852 925 1001 1080 1162 Columns 29 through 32 1247 1335 1426 1520 n = 33 a = 1617 p = Columns 1 through 14 1 5 12 22 35 51 70 92 117 145 176 210 247 287 Columns 15 through 28 330 376 425 477 532 590 651 715 782 852 925 1001 1080 1162 Columns 29 through 33 1247 1335 1426 1520 1617 n = 34 a = 1717 p = Columns 1 through 14 1 5 12 22 35 51 70 92 117 145 176 210 247 287 Columns 15 through 28 330 376 425 477 532 590 651 715 782 852 925 1001 1080 1162 Columns 29 through 34 1247 1335 1426 1520 1617 1717 n = 35 a = 1820 p = Columns 1 through 14 1 5 12 22 35 51 70 92 117 145 176 210 247 287 Columns 15 through 28 330 376 425 477 532 590 651 715 782 852 925 1001 1080 1162 Columns 29 through 35 1247 1335 1426 1520 1617 1717 1820 n = 36 a = 1926 p = Columns 1 through 14 1 5 12 22 35 51 70 92 117 145 176 210 247 287 Columns 15 through 28 330 376 425 477 532 590 651 715 782 852 925 1001 1080 1162 Columns 29 through 36 1247 1335 1426 1520 1617 1717 1820 1926 n = 37 a = 2035 p = Columns 1 through 14 1 5 12 22 35 51 70 92 117 145 176 210 247 287 Columns 15 through 28 330 376 425 477 532 590 651 715 782 852 925 1001 1080 1162 Columns 29 through 37 1247 1335 1426 1520 1617 1717 1820 1926 2035 n = 38 a = 2147 p = Columns 1 through 14 1 5 12 22 35 51 70 92 117 145 176 210 247 287 Columns 15 through 28 330 376 425 477 532 590 651 715 782 852 925 1001 1080 1162 Columns 29 through 38 1247 1335 1426 1520 1617 1717 1820 1926 2035 2147 n = 39 a = 2262 p = Columns 1 through 14 1 5 12 22 35 51 70 92 117 145 176 210 247 287 Columns 15 through 28 330 376 425 477 532 590 651 715 782 852 925 1001 1080 1162 Columns 29 through 39 1247 1335 1426 1520 1617 1717 1820 1926 2035 2147 2262 n = 40 a = 2380 p = Columns 1 through 14 1 5 12 22 ...

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

a = 1 p = 1 n = 2 a = 5 p = 1 5 n = 3 a = 12 p = 1 5 12 n = 4 a = 22 p = 1 5 12 22 n = 5 a = 35 p = 1 5 12 22 35 n = 6 a = 51 p = 1 5 12 22 35 51 n = 7 a = 70 p = 1 5 12 22 35 51 70 n = 8 a = 92 p = 1 5 12 22 35 51 70 92 n = 9 a = 117 p = 1 5 12 22 35 51 70 92 117 n = 10 a = 145 p = 1 5 12 22 35 51 70 92 117 145 n = 11 a = 176 p = 1 5 12 22 35 51 70 92 117 145 176 n = 12 a = 210 p = 1 5 12 22 35 51 70 92 117 145 176 210 n = 13 a = 247 p = 1 5 12 22 35 51 70 92 117 145 176 210 247 n = 14 a = 287 p = 1 5 12 22 35 51 70 92 117 145 176 210 247 287 n = 15 a = 330 p = 1 5 12 22 35 51 70 92 117 145 176 210 247 287 330 n = 16 a = 376 p = 1 5 12 22 35 51 70 92 117 145 176 210 247 287 330 376 n = 17 a = 425 p = 1 5 12 22 35 51 70 92 117 145 176 210 247 287 330 376 425 n = 18 a = 477 p = 1 5 12 22 35 51 70 92 117 145 176 210 247 287 330 376 425 477 n = 19 a = 532 p = 1 5 12 22 35 51 70 92 117 145 176 210 247 287 330 376 425 477 532 n = 20 a = 590 p = 1 5 12 22 35 51 70 92 117 145 176 210 247 287 330 376 425 477 532 590 n = 21 a = 651 p = 1 5 12 22 35 51 70 92 117 145 176 210 247 287 330 376 425 477 532 590 651 n = 22 a = 715 p = 1 5 12 22 35 51 70 92 117 145 176 210 247 287 330 376 425 477 532 590 651 715 n = 23 a = 782 p = 1 5 12 22 35 51 70 92 117 145 176 210 247 287 330 376 425 477 532 590 651 715 782 n = 24 a = 852 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 n = 25 a = 925 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 n = 26 a = 1001 p = Columns 1 through 14 1 5 12 22 35 51 70 92 117 145 176 210 247 287 Columns 15 through 26 330 376 425 477 532 590 651 715 782 852 925 1001 n = 27 a = 1080 p = Columns 1 through 14 1 5 12 22 35 51 70 92 117 145 176 210 247 287 Columns 15 through 27 330 376 425 477 532 590 651 715 782 852 925 1001 1080 n = 28 a = 1162 p = Columns 1 through 14 1 5 12 22 35 51 70 92 117 145 176 210 247 287 Columns 15 through 28 330 376 425 477 532 590 651 715 782 852 925 1001 1080 1162 n = 29 a = 1247 p = Columns 1 through 14 1 5 12 22 35 51 70 92 117 145 176 210 247 287 Columns 15 through 28 330 376 425 477 532 590 651 715 782 852 925 1001 1080 1162 Column 29 1247 n = 30 a = 1335 p = Columns 1 through 14 1 5 12 22 35 51 70 92 117 145 176 210 247 287 Columns 15 through 28 330 376 425 477 532 590 651 715 782 852 925 1001 1080 1162 Columns 29 through 30 1247 1335 n = 31 a = 1426 p = Columns 1 through 14 1 5 12 22 35 51 70 92 117 145 176 210 247 287 Columns 15 through 28 330 376 425 477 532 590 651 715 782 852 925 1001 1080 1162 Columns 29 through 31 1247 1335 1426 n = 32 a = 1520 p = Columns 1 through 14 1 5 12 22 35 51 70 92 117 145 176 210 247 287 Columns 15 through 28 330 376 425 477 532 590 651 715 782 852 925 1001 1080 1162 Columns 29 through 32 1247 1335 1426 1520 n = 33 a = 1617 p = Columns 1 through 14 1 5 12 22 35 51 70 92 117 145 176 210 247 287 Columns 15 through 28 330 376 425 477 532 590 651 715 782 852 925 1001 1080 1162 Columns 29 through 33 1247 1335 1426 1520 1617 n = 34 a = 1717 p = Columns 1 through 14 1 5 12 22 35 51 70 92 117 145 176 210 247 287 Columns 15 through 28 330 376 425 477 532 590 651 715 782 852 925 1001 1080 1162 Columns 29 through 34 1247 1335 1426 1520 1617 1717 n = 35 a = 1820 p = Columns 1 through 14 1 5 12 22 35 51 70 92 117 145 176 210 247 287 Columns 15 through 28 330 376 425 477 532 590 651 715 782 852 925 1001 1080 1162 Columns 29 through 35 1247 1335 1426 1520 1617 1717 1820 n = 36 a = 1926 p = Columns 1 through 14 1 5 12 22 35 51 70 92 117 145 176 210 247 287 Columns 15 through 28 330 376 425 477 532 590 651 715 782 852 925 1001 1080 1162 Columns 29 through 36 1247 1335 1426 1520 1617 1717 1820 1926 n = 37 a = 2035 p = Columns 1 through 14 1 5 12 22 35 51 70 92 117 145 176 210 247 287 Columns 15 through 28 330 376 425 477 532 590 651 715 782 852 925 1001 1080 1162 Columns 29 through 37 1247 1335 1426 1520 1617 1717 1820 1926 2035 n = 38 a = 2147 p = Columns 1 through 14 1 5 12 22 35 51 70 92 117 145 176 210 247 287 Columns 15 through 28 330 376 425 477 532 590 651 715 782 852 925 1001 1080 1162 Columns 29 through 38 1247 1335 1426 1520 1617 1717 1820 1926 2035 2147 n = 39 a = 2262 p = Columns 1 through 14 1 5 12 22 35 51 70 92 117 145 176 210 247 287 Columns 15 through 28 330 376 425 477 532 590 651 715 782 852 925 1001 1080 1162 Columns 29 through 39 1247 1335 1426 1520 1617 1717 1820 1926 2035 2147 2262 n = 40 a = 2380 p = Columns 1 through 14 1 5 12 22 ...

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

a = 1 p = 1 n = 2 a = 5 p = 1 5 n = 3 a = 12 p = 1 5 12 n = 4 a = 22 p = 1 5 12 22 n = 5 a = 35 p = 1 5 12 22 35 n = 6 a = 51 p = 1 5 12 22 35 51 n = 7 a = 70 p = 1 5 12 22 35 51 70 n = 8 a = 92 p = 1 5 12 22 35 51 70 92 n = 9 a = 117 p = 1 5 12 22 35 51 70 92 117 n = 10 a = 145 p = 1 5 12 22 35 51 70 92 117 145 n = 11 a = 176 p = 1 5 12 22 35 51 70 92 117 145 176 n = 12 a = 210 p = 1 5 12 22 35 51 70 92 117 145 176 210 n = 13 a = 247 p = 1 5 12 22 35 51 70 92 117 145 176 210 247 n = 14 a = 287 p = 1 5 12 22 35 51 70 92 117 145 176 210 247 287 n = 15 a = 330 p = 1 5 12 22 35 51 70 92 117 145 176 210 247 287 330 n = 16 a = 376 p = 1 5 12 22 35 51 70 92 117 145 176 210 247 287 330 376 n = 17 a = 425 p = 1 5 12 22 35 51 70 92 117 145 176 210 247 287 330 376 425 n = 18 a = 477 p = 1 5 12 22 35 51 70 92 117 145 176 210 247 287 330 376 425 477 n = 19 a = 532 p = 1 5 12 22 35 51 70 92 117 145 176 210 247 287 330 376 425 477 532 n = 20 a = 590 p = 1 5 12 22 35 51 70 92 117 145 176 210 247 287 330 376 425 477 532 590 n = 21 a = 651 p = 1 5 12 22 35 51 70 92 117 145 176 210 247 287 330 376 425 477 532 590 651 n = 22 a = 715 p = 1 5 12 22 35 51 70 92 117 145 176 210 247 287 330 376 425 477 532 590 651 715 n = 23 a = 782 p = 1 5 12 22 35 51 70 92 117 145 176 210 247 287 330 376 425 477 532 590 651 715 782 n = 24 a = 852 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 n = 25 a = 925 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 n = 26 a = 1001 p = Columns 1 through 14 1 5 12 22 35 51 70 92 117 145 176 210 247 287 Columns 15 through 26 330 376 425 477 532 590 651 715 782 852 925 1001 n = 27 a = 1080 p = Columns 1 through 14 1 5 12 22 35 51 70 92 117 145 176 210 247 287 Columns 15 through 27 330 376 425 477 532 590 651 715 782 852 925 1001 1080 n = 28 a = 1162 p = Columns 1 through 14 1 5 12 22 35 51 70 92 117 145 176 210 247 287 Columns 15 through 28 330 376 425 477 532 590 651 715 782 852 925 1001 1080 1162 n = 29 a = 1247 p = Columns 1 through 14 1 5 12 22 35 51 70 92 117 145 176 210 247 287 Columns 15 through 28 330 376 425 477 532 590 651 715 782 852 925 1001 1080 1162 Column 29 1247 n = 30 a = 1335 p = Columns 1 through 14 1 5 12 22 35 51 70 92 117 145 176 210 247 287 Columns 15 through 28 330 376 425 477 532 590 651 715 782 852 925 1001 1080 1162 Columns 29 through 30 1247 1335 n = 31 a = 1426 p = Columns 1 through 14 1 5 12 22 35 51 70 92 117 145 176 210 247 287 Columns 15 through 28 330 376 425 477 532 590 651 715 782 852 925 1001 1080 1162 Columns 29 through 31 1247 1335 1426 n = 32 a = 1520 p = Columns 1 through 14 1 5 12 22 35 51 70 92 117 145 176 210 247 287 Columns 15 through 28 330 376 425 477 532 590 651 715 782 852 925 1001 1080 1162 Columns 29 through 32 1247 1335 1426 1520 n = 33 a = 1617 p = Columns 1 through 14 1 5 12 22 35 51 70 92 117 145 176 210 247 287 Columns 15 through 28 330 376 425 477 532 590 651 715 782 852 925 1001 1080 1162 Columns 29 through 33 1247 1335 1426 1520 1617 n = 34 a = 1717 p = Columns 1 through 14 1 5 12 22 35 51 70 92 117 145 176 210 247 287 Columns 15 through 28 330 376 425 477 532 590 651 715 782 852 925 1001 1080 1162 Columns 29 through 34 1247 1335 1426 1520 1617 1717 n = 35 a = 1820 p = Columns 1 through 14 1 5 12 22 35 51 70 92 117 145 176 210 247 287 Columns 15 through 28 330 376 425 477 532 590 651 715 782 852 925 1001 1080 1162 Columns 29 through 35 1247 1335 1426 1520 1617 1717 1820 n = 36 a = 1926 p = Columns 1 through 14 1 5 12 22 35 51 70 92 117 145 176 210 247 287 Columns 15 through 28 330 376 425 477 532 590 651 715 782 852 925 1001 1080 1162 Columns 29 through 36 1247 1335 1426 1520 1617 1717 1820 1926 n = 37 a = 2035 p = Columns 1 through 14 1 5 12 22 35 51 70 92 117 145 176 210 247 287 Columns 15 through 28 330 376 425 477 532 590 651 715 782 852 925 1001 1080 1162 Columns 29 through 37 1247 1335 1426 1520 1617 1717 1820 1926 2035 n = 38 a = 2147 p = Columns 1 through 14 1 5 12 22 35 51 70 92 117 145 176 210 247 287 Columns 15 through 28 330 376 425 477 532 590 651 715 782 852 925 1001 1080 1162 Columns 29 through 38 1247 1335 1426 1520 1617 1717 1820 1926 2035 2147 n = 39 a = 2262 p = Columns 1 through 14 1 5 12 22 35 51 70 92 117 145 176 210 247 287 Columns 15 through 28 330 376 425 477 532 590 651 715 782 852 925 1001 1080 1162 Columns 29 through 39 1247 1335 1426 1520 1617 1717 1820 1926 2035 2147 2262 n = 40 a = 2380 p = Columns 1 through 14 1 5 12 22 ...

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

a = 1 p = 1 n = 2 a = 5 p = 1 5 n = 3 a = 12 p = 1 5 12 n = 4 a = 22 p = 1 5 12 22 n = 5 a = 35 p = 1 5 12 22 35 n = 6 a = 51 p = 1 5 12 22 35 51 n = 7 a = 70 p = 1 5 12 22 35 51 70 n = 8 a = 92 p = 1 5 12 22 35 51 70 92 n = 9 a = 117 p = 1 5 12 22 35 51 70 92 117 n = 10 a = 145 p = 1 5 12 22 35 51 70 92 117 145 n = 11 a = 176 p = 1 5 12 22 35 51 70 92 117 145 176 n = 12 a = 210 p = 1 5 12 22 35 51 70 92 117 145 176 210 n = 13 a = 247 p = 1 5 12 22 35 51 70 92 117 145 176 210 247 n = 14 a = 287 p = 1 5 12 22 35 51 70 92 117 145 176 210 247 287 n = 15 a = 330 p = 1 5 12 22 35 51 70 92 117 145 176 210 247 287 330 n = 16 a = 376 p = 1 5 12 22 35 51 70 92 117 145 176 210 247 287 330 376 n = 17 a = 425 p = 1 5 12 22 35 51 70 92 117 145 176 210 247 287 330 376 425 n = 18 a = 477 p = 1 5 12 22 35 51 70 92 117 145 176 210 247 287 330 376 425 477 n = 19 a = 532 p = 1 5 12 22 35 51 70 92 117 145 176 210 247 287 330 376 425 477 532 n = 20 a = 590 p = 1 5 12 22 35 51 70 92 117 145 176 210 247 287 330 376 425 477 532 590 n = 21 a = 651 p = 1 5 12 22 35 51 70 92 117 145 176 210 247 287 330 376 425 477 532 590 651 n = 22 a = 715 p = 1 5 12 22 35 51 70 92 117 145 176 210 247 287 330 376 425 477 532 590 651 715 n = 23 a = 782 p = 1 5 12 22 35 51 70 92 117 145 176 210 247 287 330 376 425 477 532 590 651 715 782 n = 24 a = 852 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 n = 25 a = 925 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 n = 26 a = 1001 p = Columns 1 through 14 1 5 12 22 35 51 70 92 117 145 176 210 247 287 Columns 15 through 26 330 376 425 477 532 590 651 715 782 852 925 1001 n = 27 a = 1080 p = Columns 1 through 14 1 5 12 22 35 51 70 92 117 145 176 210 247 287 Columns 15 through 27 330 376 425 477 532 590 651 715 782 852 925 1001 1080 n = 28 a = 1162 p = Columns 1 through 14 1 5 12 22 35 51 70 92 117 145 176 210 247 287 Columns 15 through 28 330 376 425 477 532 590 651 715 782 852 925 1001 1080 1162 n = 29 a = 1247 p = Columns 1 through 14 1 5 12 22 35 51 70 92 117 145 176 210 247 287 Columns 15 through 28 330 376 425 477 532 590 651 715 782 852 925 1001 1080 1162 Column 29 1247 n = 30 a = 1335 p = Columns 1 through 14 1 5 12 22 35 51 70 92 117 145 176 210 247 287 Columns 15 through 28 330 376 425 477 532 590 651 715 782 852 925 1001 1080 1162 Columns 29 through 30 1247 1335 n = 31 a = 1426 p = Columns 1 through 14 1 5 12 22 35 51 70 92 117 145 176 210 247 287 Columns 15 through 28 330 376 425 477 532 590 651 715 782 852 925 1001 1080 1162 Columns 29 through 31 1247 1335 1426 n = 32 a = 1520 p = Columns 1 through 14 1 5 12 22 35 51 70 92 117 145 176 210 247 287 Columns 15 through 28 330 376 425 477 532 590 651 715 782 852 925 1001 1080 1162 Columns 29 through 32 1247 1335 1426 1520 n = 33 a = 1617 p = Columns 1 through 14 1 5 12 22 35 51 70 92 117 145 176 210 247 287 Columns 15 through 28 330 376 425 477 532 590 651 715 782 852 925 1001 1080 1162 Columns 29 through 33 1247 1335 1426 1520 1617 n = 34 a = 1717 p = Columns 1 through 14 1 5 12 22 35 51 70 92 117 145 176 210 247 287 Columns 15 through 28 330 376 425 477 532 590 651 715 782 852 925 1001 1080 1162 Columns 29 through 34 1247 1335 1426 1520 1617 1717 n = 35 a = 1820 p = Columns 1 through 14 1 5 12 22 35 51 70 92 117 145 176 210 247 287 Columns 15 through 28 330 376 425 477 532 590 651 715 782 852 925 1001 1080 1162 Columns 29 through 35 1247 1335 1426 1520 1617 1717 1820 n = 36 a = 1926 p = Columns 1 through 14 1 5 12 22 35 51 70 92 117 145 176 210 247 287 Columns 15 through 28 330 376 425 477 532 590 651 715 782 852 925 1001 1080 1162 Columns 29 through 36 1247 1335 1426 1520 1617 1717 1820 1926 n = 37 a = 2035 p = Columns 1 through 14 1 5 12 22 35 51 70 92 117 145 176 210 247 287 Columns 15 through 28 330 376 425 477 532 590 651 715 782 852 925 1001 1080 1162 Columns 29 through 37 1247 1335 1426 1520 1617 1717 1820 1926 2035 n = 38 a = 2147 p = Columns 1 through 14 1 5 12 22 35 51 70 92 117 145 176 210 247 287 Columns 15 through 28 330 376 425 477 532 590 651 715 782 852 925 1001 1080 1162 Columns 29 through 38 1247 1335 1426 1520 1617 1717 1820 1926 2035 2147 n = 39 a = 2262 p = Columns 1 through 14 1 5 12 22 35 51 70 92 117 145 176 210 247 287 Columns 15 through 28 330 376 425 477 532 590 651 715 782 852 925 1001 1080 1162 Columns 29 through 39 1247 1335 1426 1520 1617 1717 1820 1926 2035 2147 2262 n = 40 a = 2380 p = Columns 1 through 14 1 5 12 22 ...

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

a = 1 p = 1 n = 2 a = 5 p = 1 5 n = 3 a = 12 p = 1 5 12 n = 4 a = 22 p = 1 5 12 22 n = 5 a = 35 p = 1 5 12 22 35 n = 6 a = 51 p = 1 5 12 22 35 51 n = 7 a = 70 p = 1 5 12 22 35 51 70 n = 8 a = 92 p = 1 5 12 22 35 51 70 92 n = 9 a = 117 p = 1 5 12 22 35 51 70 92 117 n = 10 a = 145 p = 1 5 12 22 35 51 70 92 117 145 n = 11 a = 176 p = 1 5 12 22 35 51 70 92 117 145 176 n = 12 a = 210 p = 1 5 12 22 35 51 70 92 117 145 176 210 n = 13 a = 247 p = 1 5 12 22 35 51 70 92 117 145 176 210 247 n = 14 a = 287 p = 1 5 12 22 35 51 70 92 117 145 176 210 247 287 n = 15 a = 330 p = 1 5 12 22 35 51 70 92 117 145 176 210 247 287 330 n = 16 a = 376 p = 1 5 12 22 35 51 70 92 117 145 176 210 247 287 330 376 n = 17 a = 425 p = 1 5 12 22 35 51 70 92 117 145 176 210 247 287 330 376 425 n = 18 a = 477 p = 1 5 12 22 35 51 70 92 117 145 176 210 247 287 330 376 425 477 n = 19 a = 532 p = 1 5 12 22 35 51 70 92 117 145 176 210 247 287 330 376 425 477 532 n = 20 a = 590 p = 1 5 12 22 35 51 70 92 117 145 176 210 247 287 330 376 425 477 532 590 n = 21 a = 651 p = 1 5 12 22 35 51 70 92 117 145 176 210 247 287 330 376 425 477 532 590 651 n = 22 a = 715 p = 1 5 12 22 35 51 70 92 117 145 176 210 247 287 330 376 425 477 532 590 651 715 n = 23 a = 782 p = 1 5 12 22 35 51 70 92 117 145 176 210 247 287 330 376 425 477 532 590 651 715 782 n = 24 a = 852 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 n = 25 a = 925 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 n = 26 a = 1001 p = Columns 1 through 14 1 5 12 22 35 51 70 92 117 145 176 210 247 287 Columns 15 through 26 330 376 425 477 532 590 651 715 782 852 925 1001 n = 27 a = 1080 p = Columns 1 through 14 1 5 12 22 35 51 70 92 117 145 176 210 247 287 Columns 15 through 27 330 376 425 477 532 590 651 715 782 852 925 1001 1080 n = 28 a = 1162 p = Columns 1 through 14 1 5 12 22 35 51 70 92 117 145 176 210 247 287 Columns 15 through 28 330 376 425 477 532 590 651 715 782 852 925 1001 1080 1162 n = 29 a = 1247 p = Columns 1 through 14 1 5 12 22 35 51 70 92 117 145 176 210 247 287 Columns 15 through 28 330 376 425 477 532 590 651 715 782 852 925 1001 1080 1162 Column 29 1247 n = 30 a = 1335 p = Columns 1 through 14 1 5 12 22 35 51 70 92 117 145 176 210 247 287 Columns 15 through 28 330 376 425 477 532 590 651 715 782 852 925 1001 1080 1162 Columns 29 through 30 1247 1335 n = 31 a = 1426 p = Columns 1 through 14 1 5 12 22 35 51 70 92 117 145 176 210 247 287 Columns 15 through 28 330 376 425 477 532 590 651 715 782 852 925 1001 1080 1162 Columns 29 through 31 1247 1335 1426 n = 32 a = 1520 p = Columns 1 through 14 1 5 12 22 35 51 70 92 117 145 176 210 247 287 Columns 15 through 28 330 376 425 477 532 590 651 715 782 852 925 1001 1080 1162 Columns 29 through 32 1247 1335 1426 1520 n = 33 a = 1617 p = Columns 1 through 14 1 5 12 22 35 51 70 92 117 145 176 210 247 287 Columns 15 through 28 330 376 425 477 532 590 651 715 782 852 925 1001 1080 1162 Columns 29 through 33 1247 1335 1426 1520 1617 n = 34 a = 1717 p = Columns 1 through 14 1 5 12 22 35 51 70 92 117 145 176 210 247 287 Columns 15 through 28 330 376 425 477 532 590 651 715 782 852 925 1001 1080 1162 Columns 29 through 34 1247 1335 1426 1520 1617 1717 n = 35 a = 1820 p = Columns 1 through 14 1 5 12 22 35 51 70 92 117 145 176 210 247 287 Columns 15 through 28 330 376 425 477 532 590 651 715 782 852 925 1001 1080 1162 Columns 29 through 35 1247 1335 1426 1520 1617 1717 1820 n = 36 a = 1926 p = Columns 1 through 14 1 5 12 22 35 51 70 92 117 145 176 210 247 287 Columns 15 through 28 330 376 425 477 532 590 651 715 782 852 925 1001 1080 1162 Columns 29 through 36 1247 1335 1426 1520 1617 1717 1820 1926 n = 37 a = 2035 p = Columns 1 through 14 1 5 12 22 35 51 70 92 117 145 176 210 247 287 Columns 15 through 28 330 376 425 477 532 590 651 715 782 852 925 1001 1080 1162 Columns 29 through 37 1247 1335 1426 1520 1617 1717 1820 1926 2035 n = 38 a = 2147 p = Columns 1 through 14 1 5 12 22 35 51 70 92 117 145 176 210 247 287 Columns 15 through 28 330 376 425 477 532 590 651 715 782 852 925 1001 1080 1162 Columns 29 through 38 1247 1335 1426 1520 1617 1717 1820 1926 2035 2147 n = 39 a = 2262 p = Columns 1 through 14 1 5 12 22 35 51 70 92 117 145 176 210 247 287 Columns 15 through 28 330 376 425 477 532 590 651 715 782 852 925 1001 1080 1162 Columns 29 through 39 1247 1335 1426 1520 1617 1717 1820 1926 2035 2147 2262 n = 40 a = 2380 p = Columns 1 through 14 1 5 12 22 ...