Python integer factorization code