Integer factorization implemented in C++