Primality by trial division: Difference between revisions
→Simple Version
No edit summary |
|||
Line 1,474:
<syntaxhighlight lang="d">import std.stdio, std.algorithm, std.range, std.math;
bool isPrime1(T)(in
if (n == 2)
return true;
if (n <= 1 || (n & 1) == 0)
return false;
for(
if (n % i == 0)
return false;
return true;
}
void main() {
Line 1,491 ⟶ 1,495:
{{out}}
[2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37]
===Version with excluded multiplies of 2 and 3===
Same output.
|