This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import math | |
| def is_prime(n): | |
| # Prime numbers must be greater than 1 | |
| if n < 2: | |
| return False | |
| # Check for factors from 2 up to the square root of n | |
| # This is the most efficient basic way to check for primality | |
| for i in range(2, int(math.sqrt(n)) + 1): | |
| if n % i == 0: |