GeeksforGeeks/Java/Medium/Count Total Setbits/count-total-setbits.java
<reponame>AyushAgnihotri2025/CP-Solutions//{ Driver Code Starts
import java.io.*;
import java.util.*;

class GFG {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int t;
        t = Integer.parseInt(br.readLine());
        while(t-- > 0){
            
            long N;
            N = Long.parseLong(br.readLine().trim());
            
            Solution obj = new Solution();
            long res = obj.countBits(N);
            
            System.out.println(res);
            
        }
    }
}

// } Driver Code Ends


class Solution {
    public static long countBits(long N) {
        // code here
        long count=0;
        for(int i=0;i<=N;i++){
            count+=Integer.bitCount(i);
        }
        return count;
    }
}
        
