Semiprime: Difference between revisions

Added Algol W
(add RPL)
(Added Algol W)
Line 255:
semi primes below 100: 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
semi primes below between 1670 and 1690: 1671 1673 1678 1679 1681 1685 1687 1689
</pre>
 
=={{header|ALGOL W}}==
{{Trans|C++}}
<syntaxhighlight lang="algolw">
begin % find somem semi-primes - numbers with exactly 2 prime factors %
logical procedure isSemiPrime( integer value v ) ;
begin
integer a, b, c;
a := 2; b := 0; c := v;
while b < 3 and c > 1 do begin
if c rem a = 0 then begin
c := c div a;
b := b + 1
end
else a := a + 1;
end while_b_lt_3_and_c_ne_1 ;
b = 2
end isSemiPrime ;
 
for x := 2 until 99 do begin
if isSemiPrime( x ) then writeon( i_w := 1, s_w := 0, x, " " )
end for_x
end.
</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>
 
3,043

edits