my algorithm is fine. I checked my primes and they are all prime. I forot about that temp pointer for the return value of realloc, but it isn't needed. If it can't allocate it'll exit so it doesn't matter. It wouldn't be able to calculate any higher anyway. Why don't I need I a dynamic array? I need an array to have all the prime numbers so far and I don't know how many I have so what do you suggest just guess?