Fast factorization using sieve of Eratosthenes