fork download
  1. #include <iostream>
  2. using namespace std;
  3. unsigned int countsetBits(int n){
  4. unsigned int count=0;
  5. while(n){
  6. n&=(n-1);
  7. count++;
  8. }
  9. return count;
  10. }
  11.  
  12. int main() {
  13. int n,flag=0;
  14. cout<<"enter to check or supported";
  15. cin>>n;
  16. for(int i=1;i<n;i++){
  17. if((countsetBits(i)+i)==n){
  18. flag+=1;
  19. }
  20. else{
  21. flag=0;
  22. }
  23. }
  24. if(flag==0){
  25. cout<<"Bleak number";
  26. }
  27. else{
  28. cout<<"is a suppoerted number"<<flag<<"number/s";
  29. }
  30. // your code goes here
  31. return 0;
  32. }
Success #stdin #stdout 0s 5460KB
stdin
3
stdout
enter to check or supportedis a suppoerted number1number/s