Cody

# Problem 44319. Write c^3 as sum of two squares a^2+b^2

Solution 1300953

Submitted on 19 Oct 2017 by Jonathan Leyes
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
c = 1; y_correct = []; assert(isequal(sumoftwosquares(c),y_correct))

y = []

2   Pass
c = 5; y_correct = [2 11; 5 10]; assert(isequal(sumoftwosquares(c),y_correct))

z = 1 a = 2 b = 11 o = 2 11 y = 2 11 z = 2 a = 5 b = 10 o = 2 11 5 10 y = 2 11 5 10 z = 3 a = 10 b = 5 o = 2 11 5 10 10 5 o = 2 11 5 10 z = 4 a = 11 b = 2 o = 2 11 5 10 0 0 11 2 o = 2 11 5 10 0 0

3   Pass
c = 6; y_correct = []; assert(isequal(sumoftwosquares(c),y_correct))

y = []

4   Pass
c = 10; y_correct = [10 30; 18 26]; assert(isequal(sumoftwosquares(c),y_correct))

z = 1 a = 10 b = 30 o = 10 30 y = 10 30 z = 2 a = 18 b = 26 o = 10 30 18 26 y = 10 30 18 26 z = 3 a = 26 b = 18 o = 10 30 18 26 26 18 o = 10 30 18 26 z = 4 a = 30 b = 10 o = 10 30 18 26 0 0 30 10 o = 10 30 18 26 0 0

5   Pass
c = 20; y_correct = [16 88; 40 80]; assert(isequal(sumoftwosquares(c),y_correct))

z = 1 a = 16 b = 88 o = 16 88 y = 16 88 z = 2 a = 40 b = 80 o = 16 88 40 80 y = 16 88 40 80 z = 3 a = 80 b = 40 o = 16 88 40 80 80 40 o = 16 88 40 80 z = 4 a = 88 b = 16 o = 16 88 40 80 0 0 88 16 o = 16 88 40 80 0 0

6   Pass
c = 24; y_correct = []; assert(isequal(sumoftwosquares(c),y_correct))

y = []

7   Pass
c = 40; y_correct = [80 240; 144 208]; assert(isequal(sumoftwosquares(c),y_correct))

y = [] z = 1 a = 80 b = 240 o = 80 240 y = 80 240 z = 2 a = 144 b = 208 o = 80 240 144 208 y = 80 240 144 208 z = 3 a = 208 b = 144 o = 80 240 144 208 208 144 o = 80 240 144 208 z = 4 a = 240 b = 80 o = 80 240 144 208 0 0 240 80 o = 80 240 144 208 0 0

8   Pass
c = 65; y_correct = [7 524; 65 520; 140 505; 191 488; 208 481; 260 455; 320 415; 364 377]; assert(isequal(sumoftwosquares(c),y_correct))

z = 1 a = 7 b = 524 o = 7 524 y = 7 524 z = 2 a = 65 b = 520 o = 7 524 65 520 y = 7 524 65 520 z = 3 a = 140 b = 505 o = 7 524 65 520 140 505 y = 7 524 65 520 140 505 z = 4 a = 191 b = 488 o = 7 524 65 520 140 505 191 488 y = 7 524 65 520 140 505 191 488 z = 5 a = 208 b = 481 o = 7 524 65 520 140 505 191 488 208 481 y = 7 524 65 520 140 505 191 488 208 481 z = 6 a = 260 b = 455 o = 7 524 65 520 140 505 191 488 208 481 260 455 y = 7 524 65 520 140 505 191 488 208 481 260 455 z = 7 a = 320 b = 415 o = 7 524 65 520 140 505 191 488 208 481 260 455 320 415 y = 7 524 65 520 140 505 191 488 208 481 260 455 320 415 z = 8 a = 364 b = 377 o = 7 524 65 520 140 505 191 488 208 481 260 455 320 415 364 377 y = 7 524 65 520 140 505 191 488 208 481 260 455 320 415 364 377 z = 9 a = 377 b = 364 o = 7 524 65 520 140 505 191 488 208 481 260 455 320 415 364 377 377 364 o = 7 524 65 520 140 505 191 488 208 481 260 455 320 415 364 377 z = 10 a = 415 b = 320 o = 7 524 65 520 140 505 191 488 208 481 260 455 320 415 364 377 0 0 415 320 o = 7 524 65 520 140 505 191 488 208 481 260 455 320 415 364 377 0 0 z = 11 a = 455 b = 260 o = 7 524 65 520 140 505 191 488 208 481 260 455 320 415 364 377 0 0 0 0 455 260 o = 7 524 65 520 140 505 191 488 208 481 260 455 320 415 364 377 0 0 0 0 z = 12 a = 481 b = 208 o = 7 524 65 520 140 505 191 488 208 481 260 455 320 415 364 377 0 0 0 0 0 0 481 208 o = 7 524 65 520 140 505 191 488 208 481 260 455 320 415 364 377 0 0 0 0 0 0 z = 13 a = 488 b = 191 o = 7 524 65 520 140 505 191 488 208 481 260 455 320 415 364 377 0 0 0 0 0 0 0 0 488 191 o = 7 524 65 520 140 505 191 488 208 481 260 455 320 415 364 377 0 0 0 0 0 0 0 0 z = 14 a = 505 b = 140 o = 7 524 65 520 140 505 191 488 208 481 260 455 320 415 364 377 0 0 0 0 0 0 0 0 0 0 505 140 o = 7 524 65 520 140 505 191 488 208 481 260 455 320 415 364 377 0 0 0 0 0 0 0 0 0 0 z = 15 a = 520 b = 65 o = 7 524 65 520 140 505 191 488 208 481 260 455 320 415 364 377 0 0 0 0 0 0 0 0 0 0 0 0 520 65 o = 7 524 65 520 140 505 191 488 208 481 260 455 320 415 364 377 0 0 0 0 0 0 0 0 0 0 0 0 z = 16 a = 524 b = 7 o = 7 524 65 520 140 505 191 488 208 481 260 455 320 415 364 377 0 0 0 0 0 0 0 0 0 0 0 0 0 0 524 7 o = 7 524 65 520 140 505 191 488 208 481 260 455 320 415 364 377 0 0 0 0 0 0 0 0 0 0 0 0 0 0

9   Pass
c = 100; y_correct = [280 960; 352 936; 600 800]; assert(isequal(sumoftwosquares(c),y_correct))

y = [] z = 1 a = 280 b = 960 o = 280 960 y = 280 960 z = 2 a = 352 b = 936 o = 280 960 352 936 y = 280 960 352 936 z = 3 a = 600 b = 800 o = 280 960 352 936 600 800 y = 280 960 352 936 600 800 z = 4 a = 800 b = 600 o = 280 960 352 936 600 800 800 600 o = 280 960 352 936 600 800 z = 5 a = 936 b = 352 o = 280 960 352 936 600 800 0 0 936 352 o = 280 960 352 936 600 800 0 0 z = 6 a = 960 b = 280 o = 280 960 352 936 600 800 0 0 0 0 960 280 o = 280 960 352 936 600 800 0 0 0 0

10   Pass
c = 123; y_correct = []; assert(isequal(sumoftwosquares(c),y_correct))

y = []

11   Pass
c = 340; y_correct = [408 6256;1360 6120; 1680 6040; 2280 5840; 2584 5712; 3304 5328; 3824 4968; 4080 4760]; assert(isequal(sumoftwosquares(c),y_correct))

y = [] z = 1 a = 408 b = 6256 o = 408 6256 y = 408 6256 z = 2 a = 1360 b = 6120 o = 408 6256 1360 6120 y = 408 6256 1360 6120 z = 3 a = 1680 b = 6040 o = 408 6256 1360 6120 1680 6040 y = 408 6256 1360 6120 1680 6040 z = 4 a = 2280 b = 5840 o = 408 6256 1360 6120 1680 6040 2280 5840 y = 408 6256 1360 6120 1680 6040 2280 5840 z = 5 a = 2584 b = 5712 o = 408 6256 1360 6120 1680 6040 2280 5840 2584 5712 y = 408 6256 1360 6120 1680 6040 2280 5840 2584 5712 z = 6 a = 3304 b = 5328 o = 408 6256 1360 6120 1680 6040 2280 5840 2584 5712 3304 5328 y = 408 6256 1360 6120 1680 6040 2280 5840 2584 5712 3304 5328 z = 7 a = 3824 b = 4968 o = 408 6256 1360 6120 1680 6040 2280 5840 2584 5712 3304 5328 3824 4968 y = 408 6256 1360 6120 1680 6040 2280 5840 2584 5712 3304 5328 3824 4968 z = 8 a = 4080 b = 4760 o = 408 6256 1360 6120 1680 6040 2280 5840 2584 5712 3304 5328 3824 4968 4080 4760 y = 408 6256 1360 6120 1680 6040 2280 5840 2584 5712 3304 5328 3824 4968 4080 4760 z = 9 a = 4760 b = 4080 o = 408 6256 1360 6120 1680 6040 2280 5840 2584 5712 3304 5328 3824 4968 4080 4760 4760 4080 o = 408 6256 1360 6120 1680 6040 2280 5840 2584 5712 3304 5328 3824 4968 4080 4760 z = 10 a = 4968 b = 3824 o = 408 6256 1360 6120 1680 6040 2280 5840 2584 5712 3304 5328 3824 4968 4080 4760 0 0 4968 3824 o = 408 6256 1360 6120 1680 6040 2280 5840 2584 5712 3304 5328 3824 4968 4080 4760 0 0 z = 11 a = 5328 b = 3304 o = 408 6256 1360 6120 1680 6040 2280 5840 2584 5712 3304 5328 3824 4968 4080 4760 0 0 0 0 5328 3304 o = 408 6256 1360 6120 1680 6040 2280 5840 2584 5712 3304 5328 3824 4968 4080 4760 0 0 0 0 z = 12 a = 5712 b = 2584 o = 408 6256 1360 6120 1680 6040 2280 5840 2584 5712 3304 5328 3824 4968 4080 4760 0 0 0 0 0 0 5712 2584 o = 408 6256 1360 6120 1680 6040 2280 5840 2584 5712 3304 5328 3824 4968 4080 4760 0 0 0 0 0 0 z = 13 a = 5840 b = 2280 o = 408 6256 1360 6120 1680 6040 2280 5840 2584 5712 3304 5328 3824 4968 4080 4760 0 0 0 0 0 0 0 0 5840 2280 o = 408 6256 1360 6120 1680 6040 2280 5840 2584 5712 3304 5328 3824 4968 4080 4760 0 0 0 0 0 0 0 0 z = 14 a = 6040 b = 1680 o = 408 6256 1360 6120 1680 6040 2280 5840 2584 5712 3304 5328 3824 4968 4080 4760 0 0 0 0 0 0 0 0 0 0 6040 1680 o = 408 6256 1360 6120 1680 6040 2280 5840 2584 5712 3304 5328 3824 4968 4080 4760 0 0 0 0 0 0 0 0 0 0 z = 15 a = 6120 b = 1360 o = 408 6256 1360 6120 1680 6040 2280 5840 2584 5712 3304 5328 3824 4968 4080 4760 0 0 0 0 0 0 0 0 0 0 0 0 6120 1360 o = 408 6256 1360 6120 1680 6040 2280 5840 2584 5712 3304 5328 3824 4968 4080 4760 0 0 0 0 0 0 0 0 0 0 0 0 z = 16 a = 6256 b = 408 o = 408 6256 1360 6120 1680 6040 2280 5840 2584 5712 3304 5328 3824 4968 4080 4760 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6256 408 o = 408 6256 1360 6120 1680 6040 2280 5840 2584 5712 3304 5328 3824 4968 4080 4760 0 0 0 0 0 0 0 0 0 0 0 0 0 0

12   Pass
c = 500; y_correct = [1160 11120; 2000 11000; 5000 10000; 5744 9592; 7600 8200]; assert(isequal(sumoftwosquares(c),y_correct))

y = [] z = 1 a = 1160 b = 11120 o = 1160 11120 y = 1160 11120 z = 2 a = 2000 b = 11000 o = 1160 11120 2000 11000 y = 1160 11120 2000 11000 z = 3 a = 5000 b = 10000 o = 1160 11120 2000 11000 5000 10000 y = 1160 11120 2000 11000 5000 10000 z = 4 a = 5744 b = 9592 o = 1160 11120 2000 11000 5000 10000 5744 9592 y = 1160 11120 2000 11000 5000 10000 5744 9592 z = 5 a = 7600 b = 8200 o = 1160 11120 2000 11000 5000 10000 5744 9592 7600 8200 y = 1160 11120 2000 11000 5000 10000 5744 9592 7600 8200 z = 6 a = 8200 b = 7600 o = 1160 11120 2000 11000 5000 10000 5744 9592 7600 8200 8200 7600 o = 1160 11120 2000 11000 5000 10000 5744 9592 7600 8200 z = 7 a = 9592 b = 5744 o = 1160 11120 2000 11000 5000 10000 5744 9592 7600 8200 0 0 9592 5744 o = 1160 11120 2000 11000 5000 10000 5744 9592 7600 8200 0 0 z = 8 a = 10000 b = 5000 o = 1160 11120 2000 11000 5000 10000 5744 9592 7600 8200 0 0 0 0 10000 5000 o = 1160 11120 2000 11000 5000 10000 5744 9592 7600 8200 0 0 0 0 z = 9 a = 11000 b = 2000 o = 1160 11120 2000 11000 5000 10000 5744 9592 7600 8200 0 0 0 0 0 0 11000 2000 o = 1160 11120 2000 11000 5000 10000 5744 9592 7600 8200 0 0 0 0 0 0 z = 10 a = 11120 b = 1160 o = 1160 11120 2000 11000 5000 10000 5744 9592 7600 8200 0 0 0 0 0 0 0 0 11120 1160 o = 1160 11120 2000 11000 5000 10000 5744 9592 7600 8200 0 0 0 0 0 0 0 0