Primality by trial division: Difference between revisions
Content added Content deleted
Langurmonkey (talk | contribs) m (→Functional) |
Langurmonkey (talk | contribs) m (→Functional) |
||
Line 1,688: | Line 1,688: | ||
{{trans|Perl 6}} |
{{trans|Perl 6}} |
||
Following the Perl 6 example, which states, "Integer $i is prime if it is greater than one and is divisible by none of 2, 3, up to the square root of $i" (plus an adjustment for the prime number 2). |
Following the Perl 6 example, which states, "Integer $i is prime if it is greater than one and is divisible by none of 2, 3, up to the square root of $i" (plus an adjustment for the prime number 2). |
||
<lang Langur>val .isPrime = f .i == 2 or .i > 2 and not any f(.x) .i rem .x == 0, |
<lang Langur>val .isPrime = f .i == 2 or .i > 2 and not any f(.x) .i rem .x == 0, pseries 2 to .i ^/ 2 |
||
writeln where .isPrime, series 1..100</lang> |
writeln where .isPrime, series 1..100</lang> |