6 ms·
Pretty sure isPrime can't simply be replaced with k % 2 == 0 ;)
by 19h 4y ago
Pretty sure isPrime can't simply be replaced with k % 2 == 0 ;)
- MobiusHorizons 4y agoWhat makes you think that it was?
- cyphar 4y agoThe indentation is broken, so one possible way to interpret it is: 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.
- deleted 4y ago[deleted]
- coldpie 4y agoGreat, now you tell me. * Tosses doctoral thesis in the trash.
- graton 4y agoWouldn't also need to change the function name to `isEven`?
- deleted 4y ago[deleted]
- tzot 4y agoYes, the identation is incorrect in the blog post (running the code would throw an IndentationError anyway); it's correct in the github code though.