solved using prime factorization