Cody

# Problem 2035. Check if it is a square or cube of consecutive numbers

Solution 367824

Submitted on 10 Dec 2013
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
%% x = 1; y_correct = true; assert(isequal(Sqube(x),y_correct))

Error: Assertion failed.

2   Fail
%% x = 100; y_correct = true; assert(isequal(Sqube(x),y_correct))

Error: Assertion failed.

3   Pass
%% x = [16 9 -8 1 0 1 4 27]; y_correct = true; assert(isequal(Sqube(x),y_correct))

x = Columns 1 through 5 4.0000 + 0.0000i 3.0000 + 0.0000i 0.0000 + 2.8284i 1.0000 + 0.0000i 0.0000 + 0.0000i Columns 6 through 10 1.0000 + 0.0000i 2.0000 + 0.0000i 5.1962 + 0.0000i 2.5198 + 0.0000i 2.0801 + 0.0000i Columns 11 through 15 1.0000 + 1.7321i 1.0000 + 0.0000i 0.0000 + 0.0000i 1.0000 + 0.0000i 1.5874 + 0.0000i Column 16 3.0000 + 0.0000i x = 0 1 2 3 4 y = 0 y = 1

4   Pass
%% x = [0 0]; y_correct = false; assert(isequal(Sqube(x),y_correct))

x = 0 0 0 0 x = 0 y = 0

5   Pass
%% x = [4 27 16 25 36 343]; y_correct = true; assert(isequal(Sqube(x),y_correct))

x = Columns 1 through 10 2.0000 5.1962 4.0000 5.0000 6.0000 18.5203 1.5874 3.0000 2.5198 2.9240 Columns 11 through 12 3.3019 7.0000 x = 2 3 4 5 6 y = 0 y = 1

6   Pass
%% x = [4 27 16 -25 36 343 0 7 0]; y_correct = false; assert(isequal(Sqube(x),y_correct))

x = Columns 1 through 5 2.0000 + 0.0000i 5.1962 + 0.0000i 4.0000 + 0.0000i 0.0000 + 5.0000i 6.0000 + 0.0000i Columns 6 through 10 18.5203 + 0.0000i 0.0000 + 0.0000i 2.6458 + 0.0000i 0.0000 + 0.0000i 1.5874 + 0.0000i Columns 11 through 15 3.0000 + 0.0000i 2.5198 + 0.0000i 1.4620 + 2.5323i 3.3019 + 0.0000i 7.0000 + 0.0000i Columns 16 through 18 0.0000 + 0.0000i 1.9129 + 0.0000i 0.0000 + 0.0000i x = Columns 1 through 5 0.0000 + 0.0000i 2.0000 + 0.0000i 3.0000 + 0.0000i 4.0000 + 0.0000i 0.0000 + 5.0000i Column 6 6.0000 + 0.0000i y = 0