Cody

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

Solution 3926238

Submitted on 30 Nov 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   Pass
x = 1; y_correct = true; assert(isequal(Sqube(x),y_correct))

y = 1

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

y = 10

Assertion failed.

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

y = 4.0000 + 0.0000i 3.0000 + 0.0000i 0.0000 + 2.8284i 1.0000 + 0.0000i 0.0000 + 0.0000i 1.0000 + 0.0000i 2.0000 + 0.0000i 5.1962 + 0.0000i

Assertion failed.

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

y = 0 0

Assertion failed.

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

y = 2.0000 5.1962 4.0000 5.0000 6.0000 18.5203

Assertion failed.

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

y = 2.0000 + 0.0000i 5.1962 + 0.0000i 4.0000 + 0.0000i 0.0000 + 5.0000i 6.0000 + 0.0000i 18.5203 + 0.0000i 0.0000 + 0.0000i 2.6458 + 0.0000i 0.0000 + 0.0000i

Assertion failed.

Suggested Problems

More from this Author3

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!