Primality Test | Set 1 ( Introduction and School Method ) | A school method based Python3 program to check if a number is prime ; Corner case ; Check from 2 to n - 1 ; Driver Program to test above function
def isPrime ( n ) : NEW_LINE INDENT if n <= 1 : NEW_LINE INDENT return False NEW_LINE DEDENT for i in range ( 2 , n ) : NEW_LINE INDENT if n % i == 0 : NEW_LINE INDENT return False ; NEW_LINE DEDENT DEDENT return True NEW_LINE DEDENT print ( " true " ) if isPrime ( 11 ) else print ( " false " ) NEW_LINE print ( " true " ) if isPrime ( 14 ) else print ( " false " ) NEW_LINE