Jump to content

Sieve of Eratosthenes: Difference between revisions

imported>Polarit
Line 11,519:
{{trans|D}}
<syntaxhighlight lang="langur">val .sieve = f(.limit) {
if .limit < 2: {return []
return []
}
 
var .composite = arr .limit, false
.composite[1] = true
 
for .n in 2 to.. truncate(.limit ^/ 2) + 1 {
if not .composite[.n] {
for .k = .n^2 ; .k < .limit ; .k += .n {
.composite[.k] = true
}
890

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.