Cody

Problem 44360. Pentagonal Numbers

Solution 1302307

Submitted on 19 Oct 2017
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   Fail
x1 = 1; x2 = 25; [p,d] = pentagonal_numbers(x1,x2) assert(isequal(p,[1,5,12,22])) assert(isequal(d,[0,1,0,0]))

Subscript indices must either be real positive integers or logicals. Error in pentagonal_numbers (line 4) while num(end)<x2 Error in Test1 (line 2) [p,d] = pentagonal_numbers(x1,x2)

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

Subscript indices must either be real positive integers or logicals. Error in pentagonal_numbers (line 4) while num(end)<x2 Error in Test2 (line 2) [p,d] = pentagonal_numbers(x1,x2)

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

Subscript indices must either be real positive integers or logicals. Error in pentagonal_numbers (line 4) while num(end)<x2 Error in Test3 (line 2) [p,d] = pentagonal_numbers(x1,x2)

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

Subscript indices must either be real positive integers or logicals. Error in pentagonal_numbers (line 4) while num(end)<x2 Error in Test4 (line 2) [p,d] = pentagonal_numbers(x1,x2)

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

Subscript indices must either be real positive integers or logicals. Error in pentagonal_numbers (line 4) while num(end)<x2 Error in Test5 (line 2) [p,d] = pentagonal_numbers(x1,x2)

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

Subscript indices must either be real positive integers or logicals. Error in pentagonal_numbers (line 4) while num(end)<x2 Error in Test6 (line 2) [p,d] = pentagonal_numbers(x1,x2)

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

Subscript indices must either be real positive integers or logicals. Error in pentagonal_numbers (line 4) while num(end)<x2 Error in Test7 (line 2) [p,d] = pentagonal_numbers(x1,x2)

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

Subscript indices must either be real positive integers or logicals. Error in pentagonal_numbers (line 4) while num(end)<x2 Error in Test8 (line 2) [p,d] = pentagonal_numbers(x1,x2)

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

Subscript indices must either be real positive integers or logicals. Error in pentagonal_numbers (line 4) while num(end)<x2 Error in Test9 (line 2) [p,d] = pentagonal_numbers(x1,x2)

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

Subscript indices must either be real positive integers or logicals. Error in pentagonal_numbers (line 4) while num(end)<x2 Error in Test10 (line 2) [p,d] = pentagonal_numbers(x1,x2)

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

Subscript indices must either be real positive integers or logicals. Error in pentagonal_numbers (line 4) while num(end)<x2 Error in Test11 (line 2) [p,d] = pentagonal_numbers(x1,x2)

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

Subscript indices must either be real positive integers or logicals. Error in pentagonal_numbers (line 4) while num(end)<x2 Error in Test12 (line 2) [p,d] = pentagonal_numbers(x1,x2)

Suggested Problems

More from this Author139