Semiprime: Difference between revisions

added MiniScript example
m (→‎{{Header|Factor}}: add whitespace)
(added MiniScript example)
Line 1,106:
<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|Mathematica}}==
<lang MiniScript>isSemiprime = function(num)
divisor = 2
primes = 0
while primes < 3 and num != 1
if num % divisor == 0 then
num = num / divisor;
primes = primes + 1
else
divisor = divisor + 1
end if
end while
return primes == 2
end function
 
print "Semiprimes up to 100:"
results = []
for i in range(2, 100)
if isSemiprime(i) then results.push i
end for
print results</lang>
 
{{output}}
<pre>Semiprimes up to 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]</pre>
 
=={{header|Nim}}==
222

edits