Cody

Solution 1722483

Submitted on 7 Feb 2019
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
n = 1; out = 4; assert(isequal(next_square(n),out));

2   Fail
n = [5 7 9]; out = [9 9 16]; assert(isequal(next_square(n),out));

Error using ^ Incorrect dimensions for raising a matrix to a power. Check that the matrix is square and the power is a scalar. To perform elementwise matrix powers, use '.^'. Error in next_square (line 2) y = (floor(sqrt(x))+1)^2; Error in Test2 (line 3) assert(isequal(next_square(n),out));

3   Fail
n = 10.^(1:5); out = [16 121 1024 10201 100489]; assert(isequal(next_square(n),out));

Error using ^ Incorrect dimensions for raising a matrix to a power. Check that the matrix is square and the power is a scalar. To perform elementwise matrix powers, use '.^'. Error in next_square (line 2) y = (floor(sqrt(x))+1)^2; Error in Test3 (line 3) assert(isequal(next_square(n),out));

4   Fail
n = round(7.^(3:.5:8)); out = [361 961 2500 6400 16900 44521 118336 311364 824464 2181529 5769604]; assert(isequal(next_square(n),out));

Error using ^ Incorrect dimensions for raising a matrix to a power. Check that the matrix is square and the power is a scalar. To perform elementwise matrix powers, use '.^'. Error in next_square (line 2) y = (floor(sqrt(x))+1)^2; Error in Test4 (line 3) assert(isequal(next_square(n),out));

Suggested Problems

More from this Author2