Primality by trial division: Difference between revisions

Content added Content deleted
m (→‎{{header|Wren}}: Minor tidy)
Line 3,029: Line 3,029:
=== Recursive ===
=== Recursive ===
{{trans|Go}}
{{trans|Go}}
{{works with|langur|0.11}}
<syntaxhighlight lang="langur">val .isPrime = f(.i) {
<syntaxhighlight lang="langur">val .isPrime = f(.i) {
val .n = abs(.i)
val .n = abs(.i)
Line 3,052: Line 3,051:
Below, we use an implied parameter (.i) on the .isPrime function.
Below, we use an implied parameter (.i) on the .isPrime function.


{{works with|langur|0.11}}
<syntaxhighlight lang="langur">val .isPrime = f .i == 2 or
<syntaxhighlight lang="langur">val .isPrime = f .i == 2 or
.i > 2 and not any f(.x) .i div .x, pseries 2 .. .i ^/ 2
.i > 2 and not any f(.x) .i div .x, pseries 2 .. .i ^/ 2