def is_prime(n):
'''
Determines whether a given number n is prime
'''
for d in range(2, n):
if n % d == 0:
# found a divisor, n is not prime
return False
# did not find any divisor, n must be prime
return True
def is_prime_alt(n):
'''
Determines whether a given number n is prime.
Alternate version only checks divisors up to the
square root of n.
'''
d = 1
while d * d <= n:
if n % d == 0:
# found a divisor, n is not prime
return False
d += 1
# did not find any divisor, n must be prime
return True
def next_prime(n):
'''
Returns the next prime number that is strictly
greater than n.
'''
p = n + 1
while not is_prime(p):
p += 1
return p
# Try it out
print(next_prime(33))