(Hint. You will find it useful to have another variable that keeps track of how many numbers have already been written. Keep going until the number written is equal to howMany.)
For this problem, a function isPrime(n) is available to you, which yields true if n is prime.