Added function to generate primes up to n