Woodall Number | CPP program to check if a number is Woodball or not . ; If number is even , return false . ; If x is 1 , return true . ; While x is divisible by 2 ; Divide x by 2 ; Count the power ; If at any point power and x became equal , return true . ; Driven Program
#include <bits/stdc++.h> NEW_LINE using namespace std ; bool isWoodall ( int x ) { if ( x % 2 == 0 ) return false ; if ( x == 1 ) return true ; int p = 0 ; while ( x % 2 == 0 ) { x = x / 2 ; p ++ ; if ( p == x ) return true ; } return false ; } int main ( ) { int x = 383 ; ( isWoodall ( x ) ) ? ( cout << " Yes " << endl ) : ( cout << " No " << endl ) ; return 0 ; }