|
|
Line 3,027: |
Line 3,027: |
|
|
|
|
|
=={{header|langur}}== |
|
=={{header|langur}}== |
|
⚫ |
|
|
⚫ |
|
|
⚫ |
following the Raku 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) |
|
|
|
|
⚫ |
Below, we use an implied parameter (.i) on the .isPrime function. |
|
|
|
|
⚫ |
<syntaxhighlight lang="langur">val .isPrime = f .i == 2 or |
|
⚫ |
.i > 2 and not any f(.x) .i div .x, pseries 2 .. .i ^/ 2 |
|
|
|
|
⚫ |
writeln filter .isPrime, series 100</syntaxhighlight> |
|
|
|
|
=== Recursive === |
|
=== Recursive === |
|
{{trans|Go}} |
|
{{trans|Go}} |
Line 3,042: |
Line 3,053: |
|
return .n ndiv 2 and .chkdiv(.n, 3) |
|
return .n ndiv 2 and .chkdiv(.n, 3) |
|
} |
|
} |
|
|
|
⚫ |
writeln filter .isPrime, series 100</syntaxhighlight> |
|
|
|
|
⚫ |
|
|
⚫ |
|
|
⚫ |
following the Raku 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) |
|
|
|
|
⚫ |
Below, we use an implied parameter (.i) on the .isPrime function. |
|
|
|
|
⚫ |
<syntaxhighlight lang="langur">val .isPrime = f .i == 2 or |
|
⚫ |
.i > 2 and not any f(.x) .i div .x, pseries 2 .. .i ^/ 2 |
|
|
|
|
|
|
writeln filter .isPrime, series 100</syntaxhighlight> |
|
writeln filter .isPrime, series 100</syntaxhighlight> |