handle edge for factors and calc primes