Cody

# Problem 45964. Compute the nth Pythagorean prime

Solution 2595955

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

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

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

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

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

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

### Community Treasure Hunt

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

Start Hunting!