Cody

Problem 45964. Compute the nth Pythagorean prime

Solution 2595910

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)

ans = 5

Output argument "pp" (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)

ans = 37

Output argument "pp" (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)

ans = 257

Output argument "pp" (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)

Index exceeds the number of array elements (116). Error in PythagoreanPrime (line 8) s(n) 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)

Index exceeds the number of array elements (468). Error in PythagoreanPrime (line 8) s(n) 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)

Index exceeds the number of array elements (1974). Error in PythagoreanPrime (line 8) s(n) 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)

Index exceeds the number of array elements (8469). Error in PythagoreanPrime (line 8) s(n) 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!