Primality by trial division: Difference between revisions
→{{header|langur}}
(Correction error for 3 aarch64 assembly) |
Langurmonkey (talk | contribs) |
||
Line 1,809:
=== Recursive ===
{{trans|Go}}
{{works with|langur|0.8.1}}
<lang langur>val .isPrime = f(.i) {
val .n = abs(.i)
if .n <= 2:
val .chkdiv = f(.n, .i) {
if .i x .i <= .n {
return .n
}
return true
}
return .n
}
Line 1,830 ⟶ 1,829:
{{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)
{{works with|langur|0.8.1}}
<lang langur>val .isPrime = f .i == 2 or .i > 2 and not any f(.x) .i
writeln where .isPrime, series 100</lang>
|