Lucas-Lehmer test: Difference between revisions

Content added Content deleted
Line 2,281: Line 2,281:
=={{header|langur}}==
=={{header|langur}}==
{{trans|D}}
{{trans|D}}
It is theoretically possible to test to the 47th Mersenne prime, as stated in the task description, but it could take a while. As for the limit, it would be very high.
It is theoretically possible to test to the 47th Mersenne prime, as stated in the task description, but it could take a while. As for the limit, it would be extremely high.


<syntaxhighlight lang="langur">val .isPrime = fn(.i) {
<syntaxhighlight lang="langur">val .isPrime = fn(.i) {
.i == 2 or .i > 2 and
.i == 2 or .i > 2 and
not any(fn(.x) { .i div .x }, pseries 2 .. .i ^/ 2)
not any(fn .x: .i div .x, pseries 2 .. .i ^/ 2)
}
}


Line 2,298: Line 2,298:
}
}


writeln join " ", map fn(.x) { $"M\.x;" }, filter .isMersennePrime, series 2300
writeln join " ", map fn .x: "M{{.x}}", filter .isMersennePrime, series 2300
</syntaxhighlight>
</syntaxhighlight>