Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- int main() {
- unsigned int n;
- std::cin >> n;
- bool isPowerOfTwo = false;
- for (int i = 1;i>0 ; i++) {
- if (n == 1) {
- isPowerOfTwo = true;
- break;
- }
- else {
- if (n % 2 == 0) {
- n = n / 2;
- }
- else {
- isPowerOfTwo = false;
- break;
- }
- }
- }
- std::cout << isPowerOfTwo;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement