Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <math.h>
- main(){
- int n,i,a,p,somme,count;
- count=0;
- for( n=1; n<1000; n++ ){
- somme=0;
- a=n;
- p=(int) ((log(n))/(log(2)));
- for( i=1; i<=p; i++ ){
- a=(int) a/2;
- somme+=a;
- }
- if( somme==n-1 ){
- count++;
- printf("%d ", n);
- }
- }
- printf("\nNombre d'entiers repondant au probleme : %d\n", count);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement