Number of values of b such that a = b + ( a ^ b ) | Java program to find the number of values of b such that a = b + ( a ^ b ) ; function to return the number of solutions ; check for every possible value ; Driver Code
import java . io . * ; class GFG { static int countSolutions ( int a ) { int count = 0 ; for ( int i = 0 ; i <= a ; i ++ ) { if ( a == ( i + ( a ^ i ) ) ) count ++ ; } return count ; } public static void main ( String [ ] args ) { int a = 3 ; System . out . println ( countSolutions ( a ) ) ; } }