Checks for primes and factors and outputs results