How many 1-bits are there in a 2^20 sized array with numbers in sequence from 0 to 2^20 - 1?

'''

#this is to get how many one bit in a string

#use dp method

public class solution{

public int solve(){

int[]dp = new int[20];

dp[0] = 1;

for(int i = 1; i < 20; i++){

dp[i] = (dp[i - 1] << 1) + (1 <<(i));

}

return dp[19];

}

}

'''