in this code i am counting the number of bits present in the numbers from 1, 2, 3....n i.e the total number of the set bits present in all the numbers till n, what should be the complexlity of this code of mine please any one tell and also how it should be calculate.
#include <iostream>
#include <vector>
#include <bitset>
using namespace std;
int main()
{
int n, count, m, k;
count = 0;
cin >> n;
n++;
while ( n-- ) {
for ( int i = 0; i <= n ; i++ ) {
if ( (1 << i) > n ) {
break;
}
k = ( 1 << i );
m = k | n;
if ( m == n ) count++;
}
}
cout << count;
return 0;
}