Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdlib.h>
- #include<stdio.h>
- int main()
- {
- int n,i,j,s=0;
- printf("Dati n= ");
- scanf("%d", &n);
- for (i = 1; i <= n; i++)
- {
- for (j = 7; j >= 0; j--)
- {
- if ((i >> j) & 1)
- s += 1;
- }
- }
- printf("s= %d\n", s);
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment