Cody

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

Solution 1398527

Submitted on 30 Dec 2017 by Jafar Ala
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))

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

y = 2 11 5^5=2^2+11^2 y = 2 11 5 10 5^5=5^2+10^2

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

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

y = 10 30 10^5=10^2+30^2 y = 10 30 18 26 10^5=18^2+26^2

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

y = 16 88 20^5=16^2+88^2 y = 16 88 40 80 20^5=40^2+80^2

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

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

y = 80 240 40^5=80^2+240^2 y = 80 240 144 208 40^5=144^2+208^2

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))

y = 7 524 65^5=7^2+524^2 y = 7 524 65 520 65^5=65^2+520^2 y = 7 524 65 520 140 505 65^5=140^2+505^2 y = 7 524 65 520 140 505 191 488 65^5=191^2+488^2 y = 7 524 65 520 140 505 191 488 208 481 65^5=208^2+481^2 y = 7 524 65 520 140 505 191 488 208 481 260 455 65^5=260^2+455^2 y = 7 524 65 520 140 505 191 488 208 481 260 455 320 415 65^5=320^2+415^2 y = 7 524 65 520 140 505 191 488 208 481 260 455 320 415 364 377 65^5=364^2+377^2

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

y = 280 960 100^5=280^2+960^2 y = 280 960 352 936 100^5=352^2+936^2 y = 280 960 352 936 600 800 100^5=600^2+800^2

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

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 = 408 6256 340^5=408^2+6256^2 y = 408 6256 1360 6120 340^5=1360^2+6120^2 y = 408 6256 1360 6120 1680 6040 340^5=1680^2+6040^2 y = 408 6256 1360 6120 1680 6040 2280 5840 340^5=2280^2+5840^2 y = 408 6256 1360 6120 1680 6040 2280 5840 2584 5712 340^5=2584^2+5712^2 y = 408 6256 1360 6120 1680 6040 2280 5840 2584 5712 3304 5328 340^5=3304^2+5328^2 y = 408 6256 1360 6120 1680 6040 2280 5840 2584 5712 3304 5328 3824 4968 340^5=3824^2+4968^2 y = 408 6256 1360 6120 1680 6040 2280 5840 2584 5712 3304 5328 3824 4968 4080 4760 340^5=4080^2+4760^2

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

y = 1160 11120 500^5=1160^2+11120^2 y = 1160 11120 2000 11000 500^5=2000^2+11000^2 y = 1160 11120 2000 11000 5000 10000 500^5=5000^2+10000^2 y = 1160 11120 2000 11000 5000 10000 5744 9592 500^5=5744^2+9592^2 y = 1160 11120 2000 11000 5000 10000 5744 9592 7600 8200 500^5=7600^2+8200^2

Community Treasure Hunt

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

Start Hunting!