I put code tags around your source - you can see how much easier it is to read, as it preserves spacing and does color high-lighting.
and the previous poster is correct. You have given us conflicting requirements. If you don't want to use some dynamically sized array, you must use a fixed size. But, you don't want to use a fixed size due to the wasted space.
You have to decide, as the designer, which requirement is more important, and discard the other.
Or...you could do a total hack...as you find the factors, you could append them to a
string with a separator, then parse that when you are done to figure out how many there are...but that is kind of like using a dynamic array since the string will have to change its size to accommodate each additional factor.