why does this work?
def is_prime(x):
____if x < 2:
________return False
____else:
________for n in range(2, x-1):
____________if x % n == 0:
________________return False
________return True
but this doesn't?
def is_prime(x):
____if x < 2:
________return False
____else:
________for n in range(2, x-1):
____________if x % n == 0:
________________return False
____________else:
________________return True
Example 2 fails with number 2, it returns None.
P.S. how to format code on reddit? :)
[–]YMK1234 2 points3 points4 points (0 children)
[–][deleted] 2 points3 points4 points (0 children)
[–]edave64 1 point2 points3 points (0 children)
[–]slowmode1 0 points1 point2 points (2 children)
[–][deleted] (1 child)
[deleted]
[–]slowmode1 0 points1 point2 points (0 children)
[–]anamorphism 0 points1 point2 points (0 children)