Vantieghems Theorem for Primality Test | Javascript code to verify Vantieghem 's Theorem ; Check if above condition is satisfied ; product of previous powers of 2 ; Driver Code
function checkVantieghemsTheorem ( limit ) { let prod = 1 ; for ( let n = 2 ; n < limit ; n ++ ) { if ( n == 2 ) document . write ( 2 + " " + " " ) ; if ( ( ( prod - n ) % ( ( 1 << n ) - 1 ) ) == 0 ) document . write ( n + " " + " " ) ; prod *= ( ( 1 << n ) - 1 ) ; } } checkVantieghemsTheorem ( 10 ) ;