Here is a solution written in C#.
It takes less than 20 milliseconds to find all the prime numbers up to 100000. About 5 seconds to find all up to 10 millions.
My PC is an AMD FX6100 @ 3.3G.
private static void Main(string[] args)
{
var sw = Stopwatch.StartNew();
var collection = new List<int>();
for (int i = 3; i < 100000; i += 2)
{
double root = Math.Sqrt(i);
bool found = false;
for (int k = 0, count = collection.Count; k < count; k++)
{
int divisor;
if ((divisor = collection[k]) > root)
{
break;
}
else if ((i % divisor) == 0)
{
found = true;
break;
}
}
if (found == false)
{
collection.Add(i);
}
}
collection.Insert(0, 2);
Console.WriteLine("time=" + sw.ElapsedMilliseconds);
Console.WriteLine("count=" + collection.Count);
Console.ReadKey();
}