Better factorization algorithm Problem 12