Pretty sure isPrime can't simply be replaced with k % 2 == 0 ;)
* Tosses doctoral thesis in the trash.
def is_prime(n: int):
result = True
for k in range(2, int(n ** 0.5) + 1):
if n % k == 0:
result = False
break
return result
Which is just a more complicated (n % 2 != 0). Obviously the break should be in the if block.