Vantieghems Theorem for Primality Test | Python3 code to verify Vantieghem 's Theorem ; Check if above condition is satisfied ; Product of previous powers of 2 ; Driver code
def checkVantieghemsTheorem ( limit ) : NEW_LINE INDENT prod = 1 NEW_LINE for n in range ( 2 , limit ) : NEW_LINE INDENT if n == 2 : NEW_LINE INDENT print ( 2 , " is ▁ prime " ) NEW_LINE DEDENT if ( ( ( prod - n ) % ( ( 1 << n ) - 1 ) ) == 0 ) : NEW_LINE INDENT print ( n , " is ▁ prime " ) NEW_LINE DEDENT prod *= ( ( 1 << n ) - 1 ) NEW_LINE DEDENT DEDENT checkVantieghemsTheorem ( 10 ) NEW_LINE