Rewrote factor.c in C++. Needs further testing after rewriting primes.c