using System.Collections.Generic;
public static void Main()
foreach (int prime in GetPrimes(100,200)) {
Console.Write(prime.ToString()+" ");
private static List<int> GetPrimes(int lo, int hi)
var primes = new List<int> {2};
for (int i = 3; i <= hi; i+=2) {
var maxFactor = Math.Sqrt(i);
foreach (int factor in primes) {
if (factor > maxFactor) break;
return primes.Where(p => lo <= p && p <= hi).ToList();