You are viewing a single comment's thread. Return to all comments →
Java
public static long sumXor(long n) { if (n==0) return 1; int count = 0; String binary = Long.toBinaryString(n); for (int i=0; i < binary.length(); i++){ if (binary.charAt(i) == '0') count++; } return (long) Math.pow(2,count); }
Seems like cookies are disabled on this browser, please enable them to open this website
Sum vs XOR
You are viewing a single comment's thread. Return to all comments →
Java