Wow. My code is so disgusting useless! There is a very VERY simple solution to this problem using a single loop.

My program checks primality for all factors unnecessarily. I thought that comparing single digits would be quicker than iterating through so many numbers but the truth is that the number gets smaller so much faster with the alternative method.

Alt is 340 times faster than my code. I'll try to improve it to lessen the gap.