Primality by trial division: Difference between revisions
Content added Content deleted
Langurmonkey (talk | contribs) m (→Functional) |
Langurmonkey (talk | contribs) |
||
Line 3,042: | Line 3,042: | ||
Below, we use an implied parameter (.i) on the .isPrime function. |
Below, we use an implied parameter (.i) on the .isPrime function. |
||
<syntaxhighlight lang="langur">val .isPrime = fn(.i) |
<syntaxhighlight lang="langur">val .isPrime = fn(.i) { |
||
.i == 2 or .i > 2 and |
|||
not any fn(.x) { .i div .x }, pseries 2 .. .i ^/ 2 |
|||
} |
|||
writeln filter .isPrime, series 100</syntaxhighlight> |
writeln filter .isPrime, series 100</syntaxhighlight> |