x = 100000 ' the length of the primes list
If x > MaxPrimesStored Then Exit Sub
Primes(1) = 2
PrimesFound = 1
NumberToTest = 3
Do While PrimesFound < x
Factor = 0
For n = 1 To PrimesFound
If Primes(n) * Primes(n) > _
NumberToTest Then Exit For
Remainder = _
NumberToTest / Primes(n) - _
Int(NumberToTest / Primes(n))
If Remainder = 0 _
Then Factor = Factor + 1
If Factor = 1 Then Exit For
Next n

