function to pass an integer and returns all primes up to that integer