Multiply all primes together. Then starting with lowest number, check to see if it can be divided evenly.

I will use arrays to keep track of factors.