Safe and Sophie Germain primes: Difference between revisions
Content added Content deleted
Line 184: | Line 184: | ||
<lang Mathematica>nextSafe[n_] := |
<lang Mathematica>nextSafe[n_] := |
||
NestWhile[NextPrime, n + 1, ! (PrimeQ[2 # + 1] && PrimeQ[#]) &] |
NestWhile[NextPrime, n + 1, ! (PrimeQ[2 # + 1] && PrimeQ[#]) &] |
||
Labeled[Partition[NestList[nextSafe, 2, 49], 10] |
Labeled[Grid[Partition[NestList[nextSafe, 2, 49], 10], |
||
Alignment -> {Right, |
|||
Baseline}], "First 50 Sophie Germain primes:", Top]</lang> |
|||
{{out}}<pre> |
{{out}}<pre> |
||
Line 193: | Line 194: | ||
359 419 431 443 491 509 593 641 653 659 |
359 419 431 443 491 509 593 641 653 659 |
||
683 719 743 761 809 911 953 1013 1019 1031 |
683 719 743 761 809 911 953 1013 1019 1031 |
||
1049 1103 1223 1229 1289 1409 1439 1451 1481 1499 |
1049 1103 1223 1229 1289 1409 1439 1451 1481 1499</pre> |
||
</pre> |
|||
=={{header|PARI/GP}}== |
=={{header|PARI/GP}}== |