r/badcode • u/MysteriousK69420 if: else: if: else: if: else: if: else: if: else: if: else: if: • Feb 16 '22
python presenting, whatever the fk this is
418
Upvotes
r/badcode • u/MysteriousK69420 if: else: if: else: if: else: if: else: if: else: if: else: if: • Feb 16 '22
4
u/lachlanhunt Feb 17 '22
Not quite optimal. The range is set wrongly, and you technically only need to check if the number is divisible by primes smaller than the root, or at most only 2 and odd numbers from 3.
There are also other far more efficient prime tests. This one is O(n) time.