Cody

Problem 45964. Compute the nth Pythagorean prime

Solution 2595934

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 = 3 3 ans = 5 3 ans = 5 2 ans = 5 5 ans = 3 3 ans = 2 2 ans = 1 4 ans = 2 1 ans = 5 3 ans = 4 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 = 3 15 ans = 11 32 ans = 7 5 ans = 2 19 ans = 14 37 ans = 36 5 ans = 34 23 ans = 21 5 ans = 18 9 ans = 1 20

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 = 42 84 ans = 183 223 ans = 38 189 ans = 29 94 ans = 246 21 ans = 128 191 ans = 226 129 ans = 86 153 ans = 217 177 ans = 46 175

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 = 1559 1005 ans = 1182 140 ans = 465 451 ans = 1013 1379 ans = 560 1204 ans = 1346 1055 ans = 406 445 ans = 1407 78 ans = 1519 252 ans = 1558 590

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 = 2625 9363 ans = 6943 9663 ans = 5144 4594 ans = 2209 5403 ans = 2183 439 ans = 3398 6763 ans = 7697 1612 ans = 1320 8355 ans = 7382 6375 ans = 10007 7616

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 = 62285 7819 ans = 1160 16325 ans = 38366 29189 ans = 50341 33727 ans = 52707 6104 ans = 40154 14564 ans = 35564 35921 ans = 48806 12182 ans = 34731 17057 ans = 47684 27189

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 = 204953 192884 ans = 54448 264427 ans = 229163 317505 ans = 307032 37415 ans = 54757 279189 ans = 17156 91825 ans = 14548 222764 ans = 32191 280584 ans = 81029 341877 ans = 317774 282814

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 Author67

Community Treasure Hunt

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

Start Hunting!