Semiprime: Difference between revisions

added Factor
(added Factor)
Line 765:
<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]
[1678; 1679]
</pre>
 
=={{Header|Factor}}==
<lang>USING: kernel math.combinatorics math.primes.factors sequences ;
: semiprime? ( n -- ? )
[ factors 2 <combinations> [ product ] map ]
[ [ = ] curry ] bi any? ;</lang>
 
Displaying the semiprimes under 100:
 
<lang>100 iota [ semiprime? ] filter [ pprint bl ] each nl</lang>
{{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>
 
1,827

edits