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
using System ; class GFG { static void checkVantieghemsTheorem ( int limit ) { long prod = 1 ; for ( long n = 2 ; n < limit ; n ++ ) { if ( ( ( prod - n < 0 ? 0 : prod - n ) % ( ( 1 << ( int ) n ) - 1 ) ) == 0 ) Console . Write ( n + " ▁ is ▁ prime STRNEWLINE " ) ; prod *= ( ( 1 << ( int ) n ) - 1 ) ; } } public static void Main ( ) { checkVantieghemsTheorem ( 10 ) ; } }