Semiprime: Difference between revisions

no edit summary
No edit summary
imported>Maxima enthusiast
No edit summary
Line 1,808:
<pre>{4, 6, 9, 10, 14, 15, 21, 22, 25, 26, 33, 34, 35, 38, 39, 46, 49, 51,
55, 57, 58, 62, 65, 69, 74, 77, 82, 85, 86, 87, 91, 93, 94, 95}</pre>
 
=={{header|Maxima}}==
<syntaxhighlight lang="maxima">
/* The first part consider the cases of squares of primes, the second part the remaining cases */
semiprimep(n):=if integerp(sqrt(n)) and primep(sqrt(n)) then true else lambda([x],length(ifactors(x))=2 and unique(map(second,ifactors(x)))=[1])(n)$
 
/* Example */
sublist(makelist(i,i,100),semiprimep);
</syntaxhighlight>
{{out}}
<pre>
[4,6,9,10,14,15,21,22,25,26,33,34,35,38,39,46,49,51,55,57,58,62,65,69,74,77,82,85,86,87,91,93,94,95]
</pre>
 
=={{header|MiniScript}}==