Primality by trial division: Difference between revisions

+Icon+Unicon
(Added Snobol4)
(+Icon+Unicon)
Line 335:
ENDIF
END</lang>
 
== Icon and Unicon ==
Procedure shown without a main program.
==={{header|Icon}}===
<lang Icon>procedure isprime(n) #: return n if prime (using trial division) or fail
if not n = integer(n) | n < 2 then fail # ensure n is an integer greater than 1
every if 0 = (n % (2 to sqrt(n))) then fail
return n
end
</lang>
==={{header|Unicon}}===
The Icon solution works in Unicon.
 
=={{header|J}}==
Anonymous user