Primality by trial division: Difference between revisions
Content added Content deleted
Not a robot (talk | contribs) (Add ABC) |
Not a robot (talk | contribs) (Add SETL) |
||
Line 4,919: | Line 4,919: | ||
Original source: [http://seed7.sourceforge.net/algorith/math.htm#is_prime] |
Original source: [http://seed7.sourceforge.net/algorith/math.htm#is_prime] |
||
=={{header|SETL}}== |
|||
<syntaxhighlight lang="setl">program trial_division; |
|||
print({n : n in {1..100} | prime n}); |
|||
op prime(n); |
|||
return n>=2 and not exists d in {2..floor sqrt n} | n mod d = 0; |
|||
end op; |
|||
end program;</syntaxhighlight> |
|||
{{out}} |
|||
<pre>{2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97}</pre> |
|||
=={{header|Sidef}}== |
=={{header|Sidef}}== |
||
<syntaxhighlight lang="ruby">func is_prime(a) { |
<syntaxhighlight lang="ruby">func is_prime(a) { |