Cody

Problem 45964. Compute the nth Pythagorean prime

Solution 2595982

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

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

2   Pass
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 a = 1 b = 6

3   Pass
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 a = 16 b = 1

4   Pass
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 a = 36 b = 19

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

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

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

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