Safe and Sophie Germain primes: Difference between revisions
Content added Content deleted
(add RPL) |
imported>Maxima enthusiast No edit summary |
||
Line 487: | Line 487: | ||
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> |
|||
=={{header|Maxima}}== |
|||
<syntaxhighlight lang="maxima"> |
|||
/* Function that generate the pairs below n */ |
|||
sg_s_pairs(n):=block( |
|||
L:makelist([i,2*i+1],i,1,n), |
|||
L1:[], |
|||
for i from 1 thru length(L) do if map(primep,L[i])=[true,true] then push(L[i],L1), |
|||
reverse(L1))$ |
|||
/* Test case */ |
|||
/* The first of the pairs is a Sophie Germain pair, first element of the pairs must be extracted */ |
|||
map(first,sg_s_pairs(1500)); |
|||
</syntaxhighlight> |
|||
{{out}} |
|||
<pre> |
|||
[2,3,5,11,23,29,41,53,83,89,113,131,173,179,191,233,239,251,281,293,359,419,431,443,491,509,593,641,653,659,683,719,743,761,809,911,953,1013,1019,1031,1049,1103,1223,1229,1289,1409,1439,1451,1481,1499] |
|||
</pre> |
</pre> |
||