Number of solutions of n = x + n âŠ • x | Function to find the number of solutions of n = n xor x ; Counter to store the number of solutions found ; Driver code
< ? php function numberOfSolutions ( $ n ) { $ c = 0 ; for ( $ x = 0 ; $ x <= $ n ; ++ $ x ) if ( $ n == $ x + $ n ^ $ x ) ++ $ c ; return $ c ; } $ n = 3 ; echo numberOfSolutions ( $ n ) ;