Vantieghems Theorem for Primality Test | C ++ code to verify Vantieghem 's Theorem ; Check if above condition is satisfied ; product of previous powers of 2 ; Driver code
#include <bits/stdc++.h> NEW_LINE using namespace std ; void checkVantieghemsTheorem ( int limit ) { long long unsigned prod = 1 ; for ( long long unsigned n = 2 ; n < limit ; n ++ ) { if ( ( ( prod - n ) % ( ( 1LL << n ) - 1 ) ) == 0 ) cout << n << " ▁ is ▁ prime STRNEWLINE " ; prod *= ( ( 1LL << n ) - 1 ) ; } } int main ( ) { checkVantieghemsTheorem ( 10 ) ; return 0 ; }