Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
IEnumerable<int> GiveMePrimeNumbers2(IEnumerable<int> numbers)
{
return numbers.Where(s => isPrime(s));
bool isPrime(int number)
{
if (number < 2)
{
return false;
}
var boundary = (int) Math.Floor(Math.Sqrt(number));
for (int i = 2; i <= boundary; ++i)
{
if (number % i == 0)
{
return false;
}
}
return true;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment