Skip to content

Instantly share code, notes, and snippets.

@nagat01
Created June 10, 2011 05:24
Show Gist options
  • Select an option

  • Save nagat01/1018277 to your computer and use it in GitHub Desktop.

Select an option

Save nagat01/1018277 to your computer and use it in GitHub Desktop.
F#: simple prime number generator
let primes =
let primes = new List<int>()
primes.Add 2
seq {
yield 2
for n in 3.. Int32.MaxValue do
if primes.All(fun p->n%p<>0) then
yield n
primes.Add n }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment