Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <algorithm>
- #include <iostream>
- #include <set>
- #include <string>
- #include <vector>
- using namespace std;
- int IsPowOfTwo(int x){
- if(x == 1)
- return true;
- if(x == 0)
- return false;
- if(x % 2 == 0)
- return IsPowOfTwo(x/2);
- return false;
- }
- int main() {
- int result = IsPowOfTwo(10);
- cout << result << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement