Cody

Problem 45964. Compute the nth Pythagorean prime

Solution 2595940

Submitted on 22 Jun 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   Fail
n = 1; pp_correct = 5; [pp1,a1,b1] = PythagoreanPrime(n); assert(isequal(pp1,pp_correct)) assert(a1 == floor(a1) && b1 == floor(b1) && a1^2+b1^2 == pp1)

pp = 5 ans = 9 25 ans = 16 4 ans = 9 1 ans = 16 1 ans = 1 4 ans = 1 16 ans = 16 4 ans = 16 4 ans = 16 1 ans = 16 4

Output argument "a" (and maybe others) not assigned during call to "PythagoreanPrime". Error in Test1 (line 3) [pp1,a1,b1] = PythagoreanPrime(n);

2   Fail
n = 5; pp_correct = 37; [pp1,a1,b1] = PythagoreanPrime(n); assert(isequal(pp1,pp_correct)) assert(a1 == floor(a1) && b1 == floor(b1) && a1^2+b1^2 == pp1)

pp = 37 ans = 441 196 ans = 484 529 ans = 1296 196 ans = 9 400 ans = 36 100 ans = 144 4 ans = 361 9 ans = 900 36 ans = 1024 4 ans = 484 1225

Output argument "a" (and maybe others) not assigned during call to "PythagoreanPrime". Error in Test2 (line 3) [pp1,a1,b1] = PythagoreanPrime(n);

3   Fail
n = 25; pp_correct = 257; [pp1,a1,b1] = PythagoreanPrime(n); assert(isequal(pp1,pp_correct)) assert(a1 == floor(a1) && b1 == floor(b1) && a1^2+b1^2 == pp1)

pp = 257 ans = 6084 4225 ans = 6889 10816 ans = 45796 3025 ans = 676 8836 ans = 2116 17689 ans = 29241 2209 ans = 19321 400 ans = 30276 61009 ans = 5625 58564 ans = 21025 6724

Output argument "a" (and maybe others) not assigned during call to "PythagoreanPrime". Error in Test3 (line 3) [pp1,a1,b1] = PythagoreanPrime(n);

4   Fail
n = 125; pp_correct = 1657; [pp1,a1,b1] = PythagoreanPrime(n); assert(isequal(pp1,pp_correct)) assert(a1 == floor(a1) && b1 == floor(b1) && a1^2+b1^2 == pp1)

pp = 1657 ans = 16129 835396 ans = 2493241 43681 ans = 2334784 180625 ans = 328329 151321 ans = 5625 1708249 ans = 1957201 1123600 ans = 1817104 2140369 ans = 106929 2500 ans = 93025 267289 ans = 2070721 1498176

Output argument "a" (and maybe others) not assigned during call to "PythagoreanPrime". Error in Test4 (line 3) [pp1,a1,b1] = PythagoreanPrime(n);

5   Fail
n = 625; pp_correct = 10313; [pp1,a1,b1] = PythagoreanPrime(n); assert(isequal(pp1,pp_correct)) assert(a1 == floor(a1) && b1 == floor(b1) && a1^2+b1^2 == pp1)

pp = 10313 ans = 4941729 45630025 ans = 86415616 5013121 ans = 47554816 16434916 ans = 51552400 964324 ans = 57410929 5612161 ans = 15800625 7678441 ans = 33965584 79174404 ans = 9042049 8059921 ans = 102880449 35105625 ans = 191844 39790864

Output argument "a" (and maybe others) not assigned during call to "PythagoreanPrime". Error in Test5 (line 3) [pp1,a1,b1] = PythagoreanPrime(n);

6   Fail
n = 3125; pp_correct = 62497; [pp1,a1,b1] = PythagoreanPrime(n); assert(isequal(pp1,pp_correct)) assert(a1 == floor(a1) && b1 == floor(b1) && a1^2+b1^2 == pp1)

pp = 62497 ans = 7778521 762422544 ans = 1.0e+09 * 1.8777 3.7853 ans = 1.0e+09 * 0.0022 2.8645 ans = 1.0e+09 * 1.1443 2.2194 ans = 1.0e+09 * 1.2192 1.4282 ans = 1.0e+09 * 0.0705 1.9750 ans = 1.0e+09 * 0.1661 1.5247 ans = 1.0e+09 * 1.4995 3.6977 ans = 1.0e+09 * 0.1465 1.2193 ans = 1.0e+09 * 1.6960 1.3988

Output argument "a" (and maybe others) not assigned during call to "PythagoreanPrime". Error in Test6 (line 3) [pp1,a1,b1] = PythagoreanPrime(n);

7   Fail
n = 15625; pp_correct = 367229; [pp1,a1,b1] = PythagoreanPrime(n); assert(isequal(pp1,pp_correct)) assert(a1 == floor(a1) && b1 == floor(b1) && a1^2+b1^2 == pp1)

pp = 367229 ans = 1.0e+10 * 4.6864 2.3739 ans = 1.0e+10 * 2.4425 2.6670 ans = 1.0e+10 * 3.9095 0.1675 ans = 1.0e+11 * 1.0709 0.0026 ans = 1.0e+10 * 3.7807 0.6255 ans = 1.0e+10 * 0.7966 2.5399 ans = 1.0e+10 * 6.0190 0.1441 ans = 1.0e+11 * 0.2208 1.1926 ans = 1.0e+10 * 8.7629 4.3885 ans = 1.0e+10 * 4.7220 0.0550

Output argument "a" (and maybe others) not assigned during call to "PythagoreanPrime". Error in Test7 (line 3) [pp1,a1,b1] = PythagoreanPrime(n);

Suggested Problems

More from this Author51

Community Treasure Hunt

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

Start Hunting!