But if you insist on finding the divisors, you can add them to a std::vector, which is a dynamically growing array. The reason is that you don't know how many divisors there's going to be (you'd know that after finding how many prime factors there are ), could be 10, could be 1000, could be a million.