import math def isprime(num): """ Returns True if the input is a prime number, False otherwise """ for i in range(2, int(math.sqrt(num)+1)): if num % i == 0: return False return True def firstprimes(num): """ Prints out the first num primes """ count = 0 # the number of primes we've printed out current = 2 # the current number we're checking while count < num: if isprime(current): print current count += 1 # same as count = count + 1 current += 1 # same as current = current + 1