Cody

# Problem 1771. Polygonal numbers

Solution 2762557

Submitted on 31 Jul 2020
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
assert(P(4,3)==9)

Output argument "y" (and maybe others) not assigned during call to "P". Error in Test1 (line 1) assert(P(4,3)==9)

2   Fail
s=3; n=1:5; y_correct=[1 3 6 10 15]; assert(isequal(P(s,n),y_correct))

Output argument "y" (and maybe others) not assigned during call to "P". Error in Test2 (line 4) assert(isequal(P(s,n),y_correct))

3   Fail
s=3:6; n=4; Y_correct=[10 16 22 28]; assert(isequal(P(s,n),Y_correct))

Output argument "y" (and maybe others) not assigned during call to "P". Error in Test3 (line 4) assert(isequal(P(s,n),Y_correct))

4   Fail
s=randi([3 1000],1,10); n=1; y_correct=ones(1,10); assert(isequal(P(s,n),y_correct))

Output argument "y" (and maybe others) not assigned during call to "P". Error in Test4 (line 4) assert(isequal(P(s,n),y_correct))

5   Fail
s=randi(1000,1,10)+2; n=5; y_correct=10*s-15; assert(isequal(P(s,n),y_correct))

Output argument "y" (and maybe others) not assigned during call to "P". Error in Test5 (line 4) assert(isequal(P(s,n),y_correct))

6   Fail
s=[5 6 7]'; n=[2 8 9]; y_correct=[5 92 117;6 120 153;7 148 189]; assert(isequal(P(s,n),y_correct))

Output argument "y" (and maybe others) not assigned during call to "P". Error in Test6 (line 4) assert(isequal(P(s,n),y_correct))

7   Fail
% for M.Z. s=[5 6 7]'; n=[2 8 9]; y_correct=[5 92 117;6 120 153;7 148 189]; assert(isequal(P(flipud(s),n),flipud(y_correct)))

Output argument "y" (and maybe others) not assigned during call to "P". Error in Test7 (line 5) assert(isequal(P(flipud(s),n),flipud(y_correct)))

8   Fail
s=randi([3,1000]); n=randi([3,1000]); assert(P(s+1,n+1)-P(s,n+1)==P(3,n))

Output argument "y" (and maybe others) not assigned during call to "P". Error in Test8 (line 3) assert(P(s+1,n+1)-P(s,n+1)==P(3,n))