Jump to content

The sieve of Sundaram: Difference between revisions

m
no edit summary
mNo edit summary
Line 1:
{{draft task}}
The sieve of ErastothenesEratosthenes: you've been there; done that; have the T-shirt. The sieve of ErastothenesEratosthenes was ancient history when Euclid was a schoolboy. You are ready for something less than 3000 years old. You are ready for The sieve of Sundaram.
 
Starting with the ordered set of +ve integers, mark every third starting at 4 (4;7;10...).
Line 18:
Using your function find and output the first 100 and the millionth Sundaram prime.
 
The faithless amongst you may compare the results with those generated by The sieve of ErastothenesEratosthenes.
 
=={{header|F_Sharp|F#}}==
<lang fsharp>
// The sieve of SudaramSundaram. Nigel Galloway: August 7th., 2021
let sPrimes()=
let sSieve=System.Collections.Generic.Dictionary<int,(unit -> int) list>()
Line 33:
 
sPrimes()|>Seq.take 100|>Seq.iter(printf "%d "); printfn ""
printfn "The millionth SudaramSundaram prime is %d" (Seq.item 999999 (sPrimes()))
</lang>
{{out}}
2,172

edits

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