moved generic method from primes to number_utils