Primality by trial division: Difference between revisions

Content added Content deleted
(Added Snobol4)
(+Icon+Unicon)
Line 335: Line 335:
ENDIF
ENDIF
END</lang>
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}}==
=={{header|J}}==