Advertisement
Guest User

Untitled

a guest
Aug 23rd, 2013
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2. #include <math.h>
  3.  
  4. main(){
  5.         int n,i,a,p,somme,count;
  6.         count=0;
  7.         for( n=1; n<1000; n++ ){
  8.                 somme=0;
  9.                 a=n;
  10.                 p=(int) ((log(n))/(log(2)));
  11.                 for( i=1; i<=p; i++ ){
  12.                         a=(int) a/2;
  13.                         somme+=a;
  14.                 }
  15.                 if( somme==n-1 ){
  16.                         count++;
  17.                         printf("%d ", n);
  18.                 }
  19.         }
  20.         printf("\nNombre d'entiers repondant au probleme : %d\n", count);
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement