Cody

Problem 44341. Hexagonal numbers on a spiral matrix

Solution 1322166

Submitted on 31 Oct 2017 by Marco Tullio
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
m = 1; y_correct = '1'; assert(isequal(hexagonalSpiral(m),y_correct))

y1 = 1 y2 = 0 y = '1'

2   Pass
m = 2; y_correct = '16'; assert(isequal(hexagonalSpiral(m),y_correct))

y1 = 16 y2 = 0 y = '16'

3   Pass
m = 5; y_correct = '1293'; assert(isequal(hexagonalSpiral(m),y_correct))

y1 = 1293 y2 = 0 y = '1293'

4   Pass
m = 16; y_correct = '420800'; assert(isequal(hexagonalSpiral(m),y_correct))

y1 = 420800 y2 = 0 y = '420800'

5   Pass
m = 100; y_correct = '4000333360'; assert(isequal(hexagonalSpiral(m),y_correct))

y1 = 4.0003e+09 y2 = 0 y = '4000333360'

6   Pass
m = 1295; y_correct = '1456830580539887'; assert(isequal(hexagonalSpiral(m),y_correct))

y1 = 1.4568e+15 y2 = 0 y = '1456830580539887'

7   Pass
m = 2500; y_correct = '39062505208334000'; assert(isequal(hexagonalSpiral(m),y_correct))

y1 = 3.9063e+12 y2 = 4000 y = '39062505208334000'

8   Pass
m = 5000; y_correct = '1250000041666668000'; assert(isequal(hexagonalSpiral(m),y_correct))

y1 = 1.2500e+14 y2 = 8000 y = '1250000041666668000'

9   Pass
m = 8000; y_correct = '13107200170666668800'; assert(isequal(hexagonalSpiral(m),y_correct))

y1 = 1.3107e+15 y2 = 8800 y = '13107200170666668800'

Suggested Problems

More from this Author62

Community Treasure Hunt

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

Start Hunting!