Semiprime: Difference between revisions

m
→‎version 2: added capital letters where appropriate. -- ~~~~
m (→‎version 2: added support for a range of numbers, added output. -- ~~~~)
m (→‎version 2: added capital letters where appropriate. -- ~~~~)
Line 177:
exit /*stick a fork in it, we're done.*/
/*──────────────────────────────────ISPRIME subroutine──────────────────*/
isprimeisPrime: procedure; parse arg x; if x<2 then return 0
if wordpos(x,'2 3 5 7')\==0 then return 1;
do i=2 for 2; if x//i==0 then return 0; end /*i*/
Line 185:
return 1
/*──────────────────────────────────ISSEMIPRIME subroutine──────────────*/
issemiprimeisSemiPrime: procedure; arg x; if \datatype(x,'W') | x<4 then return 0
x=x/1
do i=2 to 3; if x//i==0 then if isprimeisPrime(x%i) then return 1
else return 0
end /*i*/
do j=5 by 6; if j*j>x then return 0
do k=j by 2 for 2; if x//k==0 then if isprimeisPrime(x%k) then return 1
else return 0
end /*k*/