Cody

# Problem 42914. Counting the Grand Primes

Solution 941652

Submitted on 24 Aug 2016 by J.R.! Menzinger
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 = 1000; y_correct = 0; assert(isequal(grandPrimeCounter(N),y_correct))

a = Empty matrix: 1-by-0 x = 0

2   Pass
N = 1234; y_correct = 13; assert(isequal(grandPrimeCounter(N),y_correct))

a = 7 13 19 31 37 43 61 67 73 79 97 103 109 127 139 151 157 163 181 193 199 211 223 229 x = 13

3   Pass
N = 12345; y_correct = 280; assert(isequal(grandPrimeCounter(N),y_correct))

a = Columns 1 through 14 7 13 19 31 37 43 61 67 73 79 97 103 109 127 Columns 15 through 28 139 151 157 163 181 193 199 211 223 229 241 271 277 283 Columns 29 through 42 307 313 331 337 349 367 373 379 397 409 421 433 439 457 Columns 43 through 56 463 487 499 523 541 547 571 577 601 607 613 619 631 643 Columns 57 through 70 661 673 691 709 727 733 739 751 757 769 787 811 823 829 Columns 71 through 84 853 859 877 883 907 919 937 967 991 997 1009 1021 1033 1039 Columns 85 through 98 1051 1063 1069 1087 1093 1117 1123 1129 1153 1171 1201 1213 1231 1237 Columns 99 through 112 1249 1279 1291 1297 1303 1321 1327 1381 1399 1423 1429 1447 1453 1459 Columns 113 through 126 1471 1483 1489 1531 1543 1549 1567 1579 1597 1609 1621 1627 1657 1663 Columns 127 through 140 1669 1693 1699 1723 1741 1747 1753 1759 1777 1783 1789 1801 1831 1861 Columns 141 through 154 1867 1873 1879 1933 1951 1987 1993 1999 2011 2017 2029 2053 2083 2089 Columns 155 through 168 2113 2131 2137 2143 2161 2179 2203 2221 2239 2251 2269 2281 2287 2293 Columns 169 through 182 2311 2341 2347 2371 2377 2383 2389 2437 2467 2473 2503 2521 2539 2551 Columns 183 through 196 2557 2593 2617 2647 2659 2671 2677 2683 2689 2707 2713 2719 2731 2749 Columns 197 through 210 2767 2791 2797 2803 2833 2851 2857 2887 2917 2953 2971 3001 3019 3037 Columns 211 through 224 3049 3061 3067 3079 3109 3121 3163 3169 3181 3187 3217 3229 3253 3259 Columns 225 through 238 3271 3301 3307 3313 3319 3331 3343 3361 3373 3391 3433 3457 3463 3469 Columns 239 through 252 3499 3511 3517 3529 3541 3547 3559 3571 3583 3607 3613 3631 3637 3643 Columns 253 through 266 3673 3691 3697 3709 3727 3733 3739 3769 3793 3823 3847 3853 3877 3889 Columns 267 through 280 3907 3919 3931 3943 3967 4003 4021 4027 4051 4057 4093 4099 4111 4129 Columns 281 through 294 4153 4159 4177 4201 4219 4231 4243 4261 4273 4297 4327 4339 4357 4363 Columns 295 through 308 4423 4441 4447 4483 4507 4513 4519 4549 4561 4567 4591 4597 4603 4621 Columns 309 through 322 4639 4651 4657 4663 4723 4729 4759 4783 4789 4801 4813 4831 4861 4903 Columns 323 through 336 4909 4933 4951 4957 4969 4987 4993 4999 5011 5023 5059 5077 5101 5107 Columns 337 through 350 5113 5119 5167 5179 5197 5209 5227 5233 5281 5323 5347 5407 5413 5419 Columns 351 through 364 5431 5437 5443 5449 5479 5503 5521 5527 5557 5563 5569 5581 5623 5641 Columns 365 through 378 5647 5653 5659 5683 5689 5701 5737 5743 5749 5779 5791 5821 5827 5839 Columns 379 through 392 5851 5857 5869 5881 5923 5953 6007 6037 6043 6067 6073 6079 6091 6121 Columns 393 through 406 6133 6151 6163 6199 6211 6217 6229 6247 6271 6277 6301 6337 6343 6361 Columns 407 through 420 6367 6373 6379 6397 6421 6427 6451 6469 6481 6529 6547 6553 6571 6577 Columns 421 through 434 6607 6619 6637 6661 6673 6679 6691 6703 6709 6733 6763 6781 6793 6823 Columns 435 through 448 6829 6841 6871 6883 6907 6949 6961 6967 6991 6997 7027 7039 7057 7069 Columns 449 through 462 7129 7159 7177 7207 7213 7219 7237 7243 7297 7309 7321 7333 7351 7369 Columns 463 through 476 7393 7411 7417 7459 7477 7489 7507 7537 7549 7561 7573 7591 7603 7621 Columns 477 through 490 7639 7669 7681 7687 7699 7717 7723 7741 7753 7759 7789 7867 7873 7879 Columns 491 through 504 7927 7933 7951 7963 7993 8011 8017 8053 8059 8089 8101 8161 8167 8179 Columns 505 through 518 8191 8209 8221 8233 8263 8269 8287 8293 8311 8317 8329 8353 8377 8389 Columns 519 through 532 8419 8431 8443 8461 8467 8521 8527 8539 8563 8581 8599 8623 8629 8641 Columns 533 through 546 8647 8677 8689 8707 8713 8719 8731 8737 8761 8779 8803 8821 8839 8863 Columns 547 through 560 8887 8893 8923 8929 8941 8971 9001 9007 9013 9043 9049 9067 9091 9103 Columns 561 through 574 9109 9127 9133 9151 9157 9181 9187 9199 9241 9277 9283 9319 9337 9343 Columns 575 through 588 9349 9391 9397 9403 9421 9433 9439 9463 9511 9547 9601 9613 9619 9631 Columns 589 through 602 9643 9649 9661 9679 9697 9721 9733 9739 9769 9781 9787 9811 9817 9829 Columns 603 through 616 9859 9871 9883 9901 9907 9931 9949 9967 9973 10009 10039 10069 10093 10099 Columns 617 through 630 10111 10141 10159 10177 10243 10267 10273 10303 10321 10333 10357 10369 10399 10429 Columns 631 through 644 10453 10459 10477 10501 10513 10531 10567 10597 10627 10639 10651 10657 10663 10687 Columns 645 through 658 10711 10723 10729 10753 10771 10789 10831 10837 10861 10867 10891 10903 10909 10939 Columns 659 through 672 10957 10987 10993 11047 11059 11071 11083 11113 11119 11131 11149 11161 11173 11197 Columns 673 through 680 11239 11251 11257 11287 11299 11311 11317 11329 x = 280

4   Pass
N = 123456; y_correct = 1925; assert(isequal(grandPrimeCounter(N),y_correct))

a = Columns 1 through 14 7 13 19 31 37 43 61 67 73 79 97 103 109 127 Columns 15 through 28 139 151 157 163 181 193 199 211 223 229 241 271 277 283 Columns 29 through 42 307 313 331 337 349 367 373 379 397 409 421 433 439 457 Columns 43 through 56 463 487 499 523 541 547 571 577 601 607 613 619 631 643 Columns 57 through 70 661 673 691 709 727 733 739 751 757 769 787 811 823 829 Columns 71 through 84 853 859 877 883 907 919 937 967 991 997 1009 1021 1033 1039 Columns 85 through 98 1051 1063 1069 1087 1093 1117 1123 1129 1153 1171 1201 1213 1231 1237 Columns 99 through 112 1249 1279 1291 1297 1303 1321 1327 1381 1399 1423 1429 1447 1453 1459 Columns 113 through 126 1471 1483 1489 1531 1543 1549 1567 1579 1597 1609 1621 1627 1657 1663 Columns 127 through 140 1669 1693 1699 1723 1741 1747 1753 1759 1777 1783 1789 1801 1831 1861 Columns 141 through 154 1867 1873 1879 1933 1951 1987 1993 1999 2011 2017 2029 2053 2083 2089 Columns 155 through 168 2113 2131 2137 2143 2161 2179 2203 2221 2239 2251 2269 2281 2287 2293 Columns 169 through 182 2311 2341 2347 2371 2377 2383 2389 2437 2467 2473 2503 2521 2539 2551 Columns 183 through 196 2557 2593 2617 2647 2659 2671 2677 2683 2689 2707 2713 2719 2731 2749 Columns 197 through 210 2767 2791 2797 2803 2833 2851 2857 2887 2917 2953 2971 3001 3019 3037 Columns 211 through 224 3049 3061 3067 3079 3109 3121 3163 3169 3181 3187 3217 3229 3253 3259 Columns 225 through 238 3271 3301 3307 3313 3319 3331 3343 3361 3373 3391 3433 3457 3463 3469 Columns 239 through 252 3499 3511 3517 3529 3541 3547 3559 3571 3583 3607 3613 3631 3637 3643 Columns 253 through 266 3673 3691 3697 3709 3727 3733 3739 3769 3793 3823 3847 3853 3877 3889 Columns 267 through 280 3907 3919 3931 3943 3967 4003 4021 4027 4051 4057 4093 4099 4111 4129 Columns 281 through 294 4153 4159 4177 4201 4219 4231 4243 4261 4273 4297 4327 4339 4357 4363 Columns 295 through 308 4423 4441 4447 4483 4507 4513 4519 4549 4561 4567 4591 4597 4603 4621 Columns 309 through 322 4639 4651 4657 4663 4723 4729 4759 4783 4789 4801 4813 4831 4861 4903 Columns 323 through 336 4909 4933 4951 4957 4969 4987 4993 4999 5011 5023 5059 5077 5101 5107 Columns 337 through 350 5113 5119 5167 5179 5197 5209 5227 5233 5281 5323 5347 5407 5413 5419 Columns 351 through 364 5431 5437 5443 5449 5479 5503 5521 5527 5557 5563 5569 5581 5623 5641 Columns 365 through 378 5647 5653 5659 5683 5689 5701 5737 5743 5749 5779 5791 5821 5827 5839 Columns 379 through 392 5851 5857 5869 5881 5923 5953 6007 6037 6043 6067 6073 6079 6091 6121 Columns 393 through 406 6133 6151 6163 6199 6211 6217 6229 6247 6271 6277 6301 6337 6343 6361 Columns 407 through 420 6367 6373 6379 6397 6421 6427 6451 6469 6481 6529 6547 6553 6571 6577 Columns 421 through 434 6607 6619 6637 6661 6673 6679 6691 6703 6709 6733 6763 6781 6793 6823 Columns 435 through 448 6829 6841 6871 6883 6907 6949 6961 6967 6991 6997 7027 7039 7057 7069 Columns 449 through 462 7129 7159 7177 7207 7213 7219 7237 7243 7297 7309 7321 7333 7351 7369 Columns 463 through 476 7393 7411 7417 7459 7477 7489 7507 7537 7549 7561 7573 7591 7603 7621 Columns 477 through 490 7639 7669 7681 7687 7699 7717 7723 7741 7753 7759 7789 7867 7873 7879 Columns 491 through 504 7927 7933 7951 7963 7993 8011 8017 8053 8059 8089 8101 8161 8167 8179 Columns 505 through 518 8191 8209 8221 8233 8263 8269 8287 8293 8311 8317 8329 8353 8377 8389 Columns 519 through 532 8419 8431 8443 8461 8467 8521 8527 8539 8563 8581 8599 8623 8629 8641 Columns 533 through 546 8647 8677 8689 8707 8713 8719 8731 8737 8761 8779 8803 8821 8839 8863 Columns 547 through 560 8887 8893 8923 8929 8941 8971 9001 9007 9013 9043 9049 9067 9091 9103 Columns 561 through 574 9109 9127 9133 9151 9157 9181 9187 9199 9241 9277 9283 9319 9337 9343 Columns 575 through 588 9349 9391 9397 9403 9421 9433 9439 9463 9511 9547 9601 9613 9619 9631 Columns 589 through 602 9643 9649 9661 9679 9697 9721 9733 9739 9769 9781 9787 9811 9817 9829 Columns 603 through 616 9859 9871 9883 9901 9907 9931 9949 9967 9973 10009 10039 10069 10093 10099 Columns 617 through 630 10111 10141 10159 10177 10243 10267 10273 10303 10321 10333 10357 10369 10399 10429 Columns 631 through 644 10453 10459 10477 10501 10513 10531 10567 10597 10627 10639 10651 10657 10663 10687 Columns 645 through 658 10711 10723 10729 10753 10771 10789 10831 10837 10861 10867 10891 10903 10909 10939 Columns 659 through 672 10957 10987 10993 11047 11059 11071 11083 11113 11119 11131 11149 11161 11173 11197 Columns 673 through 686 11239 11251 11257 11287 11299 11311 11317 11329 11353 11383 11437 11443 11467 11491 Columns 687 through 700 11497 11503 11527 11551 11587 11593 11617 11677 11689 11701 11719 11731 11743 11779 Columns 701 through 714 11821 11827 11833 11839 11863 11887 11923 11941 11953 11959 11971 ...

5   Pass
N = 1234567; y_correct = 13142; assert(isequal(grandPrimeCounter(N),y_correct))

a = Columns 1 through 14 7 13 19 31 37 43 61 67 73 79 97 103 109 127 Columns 15 through 28 139 151 157 163 181 193 199 211 223 229 241 271 277 283 Columns 29 through 42 307 313 331 337 349 367 373 379 397 409 421 433 439 457 Columns 43 through 56 463 487 499 523 541 547 571 577 601 607 613 619 631 643 Columns 57 through 70 661 673 691 709 727 733 739 751 757 769 787 811 823 829 Columns 71 through 84 853 859 877 883 907 919 937 967 991 997 1009 1021 1033 1039 Columns 85 through 98 1051 1063 1069 1087 1093 1117 1123 1129 1153 1171 1201 1213 1231 1237 Columns 99 through 112 1249 1279 1291 1297 1303 1321 1327 1381 1399 1423 1429 1447 1453 1459 Columns 113 through 126 1471 1483 1489 1531 1543 1549 1567 1579 1597 1609 1621 1627 1657 1663 Columns 127 through 140 1669 1693 1699 1723 1741 1747 1753 1759 1777 1783 1789 1801 1831 1861 Columns 141 through 154 1867 1873 1879 1933 1951 1987 1993 1999 2011 2017 2029 2053 2083 2089 Columns 155 through 168 2113 2131 2137 2143 2161 2179 2203 2221 2239 2251 2269 2281 2287 2293 Columns 169 through 182 2311 2341 2347 2371 2377 2383 2389 2437 2467 2473 2503 2521 2539 2551 Columns 183 through 196 2557 2593 2617 2647 2659 2671 2677 2683 2689 2707 2713 2719 2731 2749 Columns 197 through 210 2767 2791 2797 2803 2833 2851 2857 2887 2917 2953 2971 3001 3019 3037 Columns 211 through 224 3049 3061 3067 3079 3109 3121 3163 3169 3181 3187 3217 3229 3253 3259 Columns 225 through 238 3271 3301 3307 3313 3319 3331 3343 3361 3373 3391 3433 3457 3463 3469 Columns 239 through 252 3499 3511 3517 3529 3541 3547 3559 3571 3583 3607 3613 3631 3637 3643 Columns 253 through 266 3673 3691 3697 3709 3727 3733 3739 3769 3793 3823 3847 3853 3877 3889 Columns 267 through 280 3907 3919 3931 3943 3967 4003 4021 4027 4051 4057 4093 4099 4111 4129 Columns 281 through 294 4153 4159 4177 4201 4219 4231 4243 4261 4273 4297 4327 4339 4357 4363 Columns 295 through 308 4423 4441 4447 4483 4507 4513 4519 4549 4561 4567 4591 4597 4603 4621 Columns 309 through 322 4639 4651 4657 4663 4723 4729 4759 4783 4789 4801 4813 4831 4861 4903 Columns 323 through 336 4909 4933 4951 4957 4969 4987 4993 4999 5011 5023 5059 5077 5101 5107 Columns 337 through 350 5113 5119 5167 5179 5197 5209 5227 5233 5281 5323 5347 5407 5413 5419 Columns 351 through 364 5431 5437 5443 5449 5479 5503 5521 5527 5557 5563 5569 5581 5623 5641 Columns 365 through 378 5647 5653 5659 5683 5689 5701 5737 5743 5749 5779 5791 5821 5827 5839 Columns 379 through 392 5851 5857 5869 5881 5923 5953 6007 6037 6043 6067 6073 6079 6091 6121 Columns 393 through 406 6133 6151 6163 6199 6211 6217 6229 6247 6271 6277 6301 6337 6343 6361 Columns 407 through 420 6367 6373 6379 6397 6421 6427 6451 6469 6481 6529 6547 6553 6571 6577 Columns 421 through 434 6607 6619 6637 6661 6673 6679 6691 6703 6709 6733 6763 6781 6793 6823 Columns 435 through 448 6829 6841 6871 6883 6907 6949 6961 6967 6991 6997 7027 7039 7057 7069 Columns 449 through 462 7129 7159 7177 7207 7213 7219 7237 7243 7297 7309 7321 7333 7351 7369 Columns 463 through 476 7393 7411 7417 7459 7477 7489 7507 7537 7549 7561 7573 7591 7603 7621 Columns 477 through 490 7639 7669 7681 7687 7699 7717 7723 7741 7753 7759 7789 7867 7873 7879 Columns 491 through 504 7927 7933 7951 7963 7993 8011 8017 8053 8059 8089 8101 8161 8167 8179 Columns 505 through 518 8191 8209 8221 8233 8263 8269 8287 8293 8311 8317 8329 8353 8377 8389 Columns 519 through 532 8419 8431 8443 8461 8467 8521 8527 8539 8563 8581 8599 8623 8629 8641 Columns 533 through 546 8647 8677 8689 8707 8713 8719 8731 8737 8761 8779 8803 8821 8839 8863 Columns 547 through 560 8887 8893 8923 8929 8941 8971 9001 9007 9013 9043 9049 9067 9091 9103 Columns 561 through 574 9109 9127 9133 9151 9157 9181 9187 9199 9241 9277 9283 9319 9337 9343 Columns 575 through 588 9349 9391 9397 9403 9421 9433 9439 9463 9511 9547 9601 9613 9619 9631 Columns 589 through 602 9643 9649 9661 9679 9697 9721 9733 9739 9769 9781 9787 9811 9817 9829 Columns 603 through 616 9859 9871 9883 9901 9907 9931 9949 9967 9973 10009 10039 10069 10093 10099 Columns 617 through 630 10111 10141 10159 10177 10243 10267 10273 10303 10321 10333 10357 10369 10399 10429 Columns 631 through 644 10453 10459 10477 10501 10513 10531 10567 10597 10627 10639 10651 10657 10663 10687 Columns 645 through 658 10711 10723 10729 10753 10771 10789 10831 10837 10861 10867 10891 10903 10909 10939 Columns 659 through 672 10957 10987 10993 11047 11059 11071 11083 11113 11119 11131 11149 11161 11173 11197 Columns 673 through 686 11239 11251 11257 11287 11299 11311 11317 11329 11353 11383 11437 11443 11467 11491 Columns 687 through 700 11497 11503 11527 11551 11587 11593 11617 11677 11689 11701 11719 11731 11743 11779 Columns 701 through 714 11821 11827 11833 11839 11863 11887 11923 11941 11953 11959 11971 ...

6   Pass
N = 99999900; y_correct = 586509; assert(isequal(grandPrimeCounter(N),y_correct))

x = 586509