Cody

# Problem 45964. Compute the nth Pythagorean prime

Solution 2595877

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)

t = 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)

t = 5 9 13 17 21

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)

t = 5 9 13 17 21 25 29 33 37 41 45 49 53 57 61 65 69 73 77 81 85 89 93 97 101

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)

t = Columns 1 through 30 5 9 13 17 21 25 29 33 37 41 45 49 53 57 61 65 69 73 77 81 85 89 93 97 101 105 109 113 117 121 Columns 31 through 60 125 129 133 137 141 145 149 153 157 161 165 169 173 177 181 185 189 193 197 201 205 209 213 217 221 225 229 233 237 241 Columns 61 through 90 245 249 253 257 261 265 269 273 277 281 285 289 293 297 301 305 309 313 317 321 325 329 333 337 341 345 349 353 357 361 Columns 91 through 120 365 369 373 377 381 385 389 393 397 401 405 409 413 417 421 425 429 433 437 441 445 449 453 457 461 465 469 473 477 481 Columns 121 through 125 485 489 493 497 501

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

t = Columns 1 through 15 5 9 13 17 21 25 29 33 37 41 45 49 53 57 61 Columns 16 through 30 65 69 73 77 81 85 89 93 97 101 105 109 113 117 121 Columns 31 through 45 125 129 133 137 141 145 149 153 157 161 165 169 173 177 181 Columns 46 through 60 185 189 193 197 201 205 209 213 217 221 225 229 233 237 241 Columns 61 through 75 245 249 253 257 261 265 269 273 277 281 285 289 293 297 301 Columns 76 through 90 305 309 313 317 321 325 329 333 337 341 345 349 353 357 361 Columns 91 through 105 365 369 373 377 381 385 389 393 397 401 405 409 413 417 421 Columns 106 through 120 425 429 433 437 441 445 449 453 457 461 465 469 473 477 481 Columns 121 through 135 485 489 493 497 501 505 509 513 517 521 525 529 533 537 541 Columns 136 through 150 545 549 553 557 561 565 569 573 577 581 585 589 593 597 601 Columns 151 through 165 605 609 613 617 621 625 629 633 637 641 645 649 653 657 661 Columns 166 through 180 665 669 673 677 681 685 689 693 697 701 705 709 713 717 721 Columns 181 through 195 725 729 733 737 741 745 749 753 757 761 765 769 773 777 781 Columns 196 through 210 785 789 793 797 801 805 809 813 817 821 825 829 833 837 841 Columns 211 through 225 845 849 853 857 861 865 869 873 877 881 885 889 893 897 901 Columns 226 through 240 905 909 913 917 921 925 929 933 937 941 945 949 953 957 961 Columns 241 through 255 965 969 973 977 981 985 989 993 997 1001 1005 1009 1013 1017 1021 Columns 256 through 270 1025 1029 1033 1037 1041 1045 1049 1053 1057 1061 1065 1069 1073 1077 1081 Columns 271 through 285 1085 1089 1093 1097 1101 1105 1109 1113 1117 1121 1125 1129 1133 1137 1141 Columns 286 through 300 1145 1149 1153 1157 1161 1165 1169 1173 1177 1181 1185 1189 1193 1197 1201 Columns 301 through 315 1205 1209 1213 1217 1221 1225 1229 1233 1237 1241 1245 1249 1253 1257 1261 Columns 316 through 330 1265 1269 1273 1277 1281 1285 1289 1293 1297 1301 1305 1309 1313 1317 1321 Columns 331 through 345 1325 1329 1333 1337 1341 1345 1349 1353 1357 1361 1365 1369 1373 1377 1381 Columns 346 through 360 1385 1389 1393 1397 1401 1405 1409 1413 1417 1421 1425 1429 1433 1437 1441 Columns 361 through 375 1445 1449 1453 1457 1461 1465 1469 1473 1477 1481 1485 1489 1493 1497 1501 Columns 376 through 390 1505 1509 1513 1517 1521 1525 1529 1533 1537 1541 1545 1549 1553 1557 1561 Columns 391 through 405 1565 1569 1573 1577 1581 1585 1589 1593 1597 1601 1605 1609 1613 1617 1621 Columns 406 through 420 1625 1629 1633 1637 1641 1645 1649 1653 1657 1661 1665 1669 1673 1677 1681 Columns 421 through 435 1685 1689 1693 1697 1701 1705 1709 1713 1717 1721 1725 1729 1733 1737 1741 Columns 436 through 450 1745 1749 1753 1757 1761 1765 1769 1773 1777 1781 1785 1789 1793 1797 1801 Columns 451 through 465 1805 1809 1813 1817 1821 1825 1829 1833 1837 1841 1845 1849 1853 1857 1861 Columns 466 through 480 1865 1869 1873 1877 1881 1885 1889 1893 1897 1901 1905 1909 1913 1917 1921 Columns 481 through 495 1925 1929 1933 1937 1941 1945 1949 1953 1957 1961 1965 1969 1973 1977 1981 Columns 496 through 510 1985 1989 1993 1997 2001 2005 2009 2013 2017 2021 2025 2029 2033 2037 2041 Columns 511 through 525 2045 2049 2053 2057 2061 2065 2069 2073 2077 2081 2085 2089 2093 2097 2101 Columns 526 through 540 2105 2109 2113 2117 2121 2125 2129 2133 2137 2141 2145 2149 2153 2157 2161 Columns 541 through 555 2165 2169 2173 2177 2181 2185 2189 2193 2197 2201 2205 2209 2213 2217 2221 Columns 556 through 570 2225 2229 2233 2237 2241 2245 2249 2253 2257 2261 2265 2269 2273 2277 2281 Columns 571 through 585 2285 2289 2293 2297 2301 2305 2309 2313 2317 2321 2325 2329 2333 2337 2341 Columns 586 through 600 2345 2349 2353 2357 2361 2365 2369 2373 2377 2381 2385 2389 2393 2397 2401 Columns 601 through 615 2405 2409 2413 2417 2421 2425 2429 2433 2437 2441 2445 2449 2453 2457 2461 Columns 616 through 625 2465 2469 2473 2477 2481 2485 2489 2493 2497 2501

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

t = Columns 1 through 15 5 9 13 17 21 25 29 33 37 41 45 49 53 57 61 Columns 16 through 30 65 69 73 77 81 85 89 93 97 101 105 109 113 117 121 Columns 31 through 45 125 129 133 137 141 145 149 153 157 161 165 169 173 177 181 Columns 46 through 60 185 189 193 197 201 205 209 213 217 221 225 229 233 237 241 Columns 61 through 75 245 249 253 257 261 265 269 273 277 281 285 289 293 297 301 Columns 76 through 90 305 309 313 317 321 325 329 333 337 341 345 349 353 357 361 Columns 91 through 105 365 369 373 377 381 385 389 393 397 401 405 409 413 417 421 Columns 106 through 120 425 429 433 437 441 445 449 453 457 461 465 469 473 477 481 Columns 121 through 135 485 489 493 497 501 505 509 513 517 521 525 529 533 537 541 Columns 136 through 150 545 549 553 557 561 565 569 573 577 581 585 589 593 597 601 Columns 151 through 165 605 609 613 617 621 625 629 633 637 641 645 649 653 657 661 Columns 166 through 180 665 669 673 677 681 685 689 693 697 701 705 709 713 717 721 Columns 181 through 195 725 729 733 737 741 745 749 753 757 761 765 769 773 777 781 Columns 196 through 210 785 789 793 797 801 805 809 813 817 821 825 829 833 837 841 Columns 211 through 225 845 849 853 857 861 865 869 873 877 881 885 889 893 897 901 Columns 226 through 240 905 909 913 917 921 925 929 933 937 941 945 949 953 957 961 Columns 241 through 255 965 969 973 977 981 985 989 993 997 1001 1005 1009 1013 1017 1021 Columns 256 through 270 1025 1029 1033 1037 1041 1045 1049 1053 1057 1061 1065 1069 1073 1077 1081 Columns 271 through 285 1085 1089 1093 1097 1101 1105 1109 1113 1117 1121 1125 1129 1133 1137 1141 Columns 286 through 300 1145 1149 1153 1157 1161 1165 1169 1173 1177 1181 1185 1189 1193 1197 1201 Columns 301 through 315 1205 1209 1213 1217 1221 1225 1229 1233 1237 1241 1245 1249 1253 1257 1261 Columns 316 through 330 1265 1269 1273 1277 1281 1285 1289 1293 1297 1301 1305 1309 1313 1317 1321 Columns 331 through 345 1325 1329 1333 1337 1341 1345 1349 1353 1357 1361 1365 1369 1373 1377 1381 Columns 346 through 360 1385 1389 1393 1397 1401 1405 1409 1413 1417 1421 1425 1429 1433 1437 1441 Columns 361 through 375 1445 1449 1453 1457 1461 1465 1469 1473 1477 1481 1485 1489 1493 1497 1501 Columns 376 through 390 1505 1509 1513 1517 1521 1525 1529 1533 1537 1541 1545 1549 1553 1557 1561 Columns 391 through 405 1565 1569 1573 1577 1581 1585 1589 1593 1597 1601 1605 1609 1613 1617 1621 Columns 406 through 420 1625 1629 1633 1637 1641 1645 1649 1653 1657 1661 1665 1669 1673 1677 1681 Columns 421 through 435 1685 1689 1693 1697 1701 1705 1709 1713 1717 1721 1725 1729 1733 1737 1741 Columns 436 through 450 1745 1749 1753 1757 1761 1765 1769 1773 1777 1781 1785 1789 1793 1797 1801 Columns 451 through 465 1805 1809 1813 1817 1821 1825 1829 1833 1837 1841 1845 1849 1853 1857 1861 Columns 466 through 480 1865 1869 1873 1877 1881 1885 1889 1893 1897 1901 1905 1909 1913 1917 1921 Columns 481 through 495 1925 1929 1933 1937 1941 1945 1949 1953 1957 1961 1965 1969 1973 1977 1981 Columns 496 through 510 1985 1989 1993 1997 2001 2005 2009 2013 2017 2021 2025 2029 2033 2037 2041 Columns 511 through 525 2045 2049 2053 2057 2061 2065 2069 2073 2077 2081 2085 2089 2093 2097 2101 Columns 526 through 540 2105 2109 2113 2117 2121 2125 2129 2133 2137 2141 2145 2149 2153 2157 2161 Columns 541 through 555 2165 2169 2173 2177 2181 2185 2189 2193 2197 2201 2205 2209 2213 2217 2221 Columns 556 through 570 2225 2229 2233 2237 2241 2245 2249 2253 2257 2261 2265 2269 2273 2277 2281 Columns 571 through 585 2285 2289 2293 2297 2301 2305 2309 2313 2317 2321 2325 2329 2333 2337 2341 Columns 586 through 600 2345 2349 2353 2357 2361 2365 2369 2373 2377 2381 2385 2389 2393 2397 2401 Columns 601 through 615 2405 2409 2413 2417 2421 2425 2429 2433 2437 2441 2445 2449 2453 2457 2461 Columns 616 through 630 2465 2469 2473 2477 2481 2485 2489 2493 2497 2501 2505 2509 2513 2517 2521 Columns 631 through 645 2525 2529 2533 2537 2541 2545 2549 2553 2557 2561 2565 2569 2573 2577 2581 Columns 646 through 660 2585 2589 2593 2597 2601 2605 2609 2613 2617 2621 2625 2629 2633 2637 2641 Columns 661 through 675 2645 2649 2653 2657 2661 2665 2669 2673 2677 2681 2685 2689 2693 2697 2701 Columns 676 through 690 2705 2709 2713 2717 2721 2725 2729 2733 2737 2741 2745 2749 2753 2757 2761 Columns 691 through 705 2765 2769 2773 2777 2781 2785 2789 2793 2797 2801 2805 2809 2813 2817 2821 Columns 706 through 720 2825 2829 2833 2837 2841 2845 2849 2853 2857 2861 2865 2869 2873 ...

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

t = Columns 1 through 15 5 9 13 17 21 25 29 33 37 41 45 49 53 57 61 Columns 16 through 30 65 69 73 77 81 85 89 93 97 101 105 109 113 117 121 Columns 31 through 45 125 129 133 137 141 145 149 153 157 161 165 169 173 177 181 Columns 46 through 60 185 189 193 197 201 205 209 213 217 221 225 229 233 237 241 Columns 61 through 75 245 249 253 257 261 265 269 273 277 281 285 289 293 297 301 Columns 76 through 90 305 309 313 317 321 325 329 333 337 341 345 349 353 357 361 Columns 91 through 105 365 369 373 377 381 385 389 393 397 401 405 409 413 417 421 Columns 106 through 120 425 429 433 437 441 445 449 453 457 461 465 469 473 477 481 Columns 121 through 135 485 489 493 497 501 505 509 513 517 521 525 529 533 537 541 Columns 136 through 150 545 549 553 557 561 565 569 573 577 581 585 589 593 597 601 Columns 151 through 165 605 609 613 617 621 625 629 633 637 641 645 649 653 657 661 Columns 166 through 180 665 669 673 677 681 685 689 693 697 701 705 709 713 717 721 Columns 181 through 195 725 729 733 737 741 745 749 753 757 761 765 769 773 777 781 Columns 196 through 210 785 789 793 797 801 805 809 813 817 821 825 829 833 837 841 Columns 211 through 225 845 849 853 857 861 865 869 873 877 881 885 889 893 897 901 Columns 226 through 240 905 909 913 917 921 925 929 933 937 941 945 949 953 957 961 Columns 241 through 255 965 969 973 977 981 985 989 993 997 1001 1005 1009 1013 1017 1021 Columns 256 through 270 1025 1029 1033 1037 1041 1045 1049 1053 1057 1061 1065 1069 1073 1077 1081 Columns 271 through 285 1085 1089 1093 1097 1101 1105 1109 1113 1117 1121 1125 1129 1133 1137 1141 Columns 286 through 300 1145 1149 1153 1157 1161 1165 1169 1173 1177 1181 1185 1189 1193 1197 1201 Columns 301 through 315 1205 1209 1213 1217 1221 1225 1229 1233 1237 1241 1245 1249 1253 1257 1261 Columns 316 through 330 1265 1269 1273 1277 1281 1285 1289 1293 1297 1301 1305 1309 1313 1317 1321 Columns 331 through 345 1325 1329 1333 1337 1341 1345 1349 1353 1357 1361 1365 1369 1373 1377 1381 Columns 346 through 360 1385 1389 1393 1397 1401 1405 1409 1413 1417 1421 1425 1429 1433 1437 1441 Columns 361 through 375 1445 1449 1453 1457 1461 1465 1469 1473 1477 1481 1485 1489 1493 1497 1501 Columns 376 through 390 1505 1509 1513 1517 1521 1525 1529 1533 1537 1541 1545 1549 1553 1557 1561 Columns 391 through 405 1565 1569 1573 1577 1581 1585 1589 1593 1597 1601 1605 1609 1613 1617 1621 Columns 406 through 420 1625 1629 1633 1637 1641 1645 1649 1653 1657 1661 1665 1669 1673 1677 1681 Columns 421 through 435 1685 1689 1693 1697 1701 1705 1709 1713 1717 1721 1725 1729 1733 1737 1741 Columns 436 through 450 1745 1749 1753 1757 1761 1765 1769 1773 1777 1781 1785 1789 1793 1797 1801 Columns 451 through 465 1805 1809 1813 1817 1821 1825 1829 1833 1837 1841 1845 1849 1853 1857 1861 Columns 466 through 480 1865 1869 1873 1877 1881 1885 1889 1893 1897 1901 1905 1909 1913 1917 1921 Columns 481 through 495 1925 1929 1933 1937 1941 1945 1949 1953 1957 1961 1965 1969 1973 1977 1981 Columns 496 through 510 1985 1989 1993 1997 2001 2005 2009 2013 2017 2021 2025 2029 2033 2037 2041 Columns 511 through 525 2045 2049 2053 2057 2061 2065 2069 2073 2077 2081 2085 2089 2093 2097 2101 Columns 526 through 540 2105 2109 2113 2117 2121 2125 2129 2133 2137 2141 2145 2149 2153 2157 2161 Columns 541 through 555 2165 2169 2173 2177 2181 2185 2189 2193 2197 2201 2205 2209 2213 2217 2221 Columns 556 through 570 2225 2229 2233 2237 2241 2245 2249 2253 2257 2261 2265 2269 2273 2277 2281 Columns 571 through 585 2285 2289 2293 2297 2301 2305 2309 2313 2317 2321 2325 2329 2333 2337 2341 Columns 586 through 600 2345 2349 2353 2357 2361 2365 2369 2373 2377 2381 2385 2389 2393 2397 2401 Columns 601 through 615 2405 2409 2413 2417 2421 2425 2429 2433 2437 2441 2445 2449 2453 2457 2461 Columns 616 through 630 2465 2469 2473 2477 2481 2485 2489 2493 2497 2501 2505 2509 2513 2517 2521 Columns 631 through 645 2525 2529 2533 2537 2541 2545 2549 2553 2557 2561 2565 2569 2573 2577 2581 Columns 646 through 660 2585 2589 2593 2597 2601 2605 2609 2613 2617 2621 2625 2629 2633 2637 2641 Columns 661 through 675 2645 2649 2653 2657 2661 2665 2669 2673 2677 2681 2685 2689 2693 2697 2701 Columns 676 through 690 2705 2709 2713 2717 2721 2725 2729 2733 2737 2741 2745 2749 2753 2757 2761 Columns 691 through 705 2765 2769 2773 2777 2781 2785 2789 2793 2797 2801 2805 2809 2813 2817 2821 Columns 706 through 720 2825 2829 2833 2837 2841 2845 2849 2853 2857 2861 2865 2869 2873 ...

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