checking if n has any factor upto square root of n if yes its not prime
for i in range ( 2 , root + 1 ) : NEW_LINE INDENT if ( n % i == 0 ) : NEW_LINE INDENT return False NEW_LINE DEDENT DEDENT return True NEW_LINE def isSandwitched ( n ) : NEW_LINE return ( isPrime ( n - 1 ) and isPrime ( n + 1 ) ) NEW_LINE