Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <unistd.h>
- int main() {
- int number = {0};
- int found = {0};
- std::cout << "Please enter int: ";
- std::cin >> number;
- std::cout << std::endl;
- if (number < 2){
- std::cout << "no";
- return 0;
- }
- while (true){
- number >>= 1;
- const int lowerBit = number & 1;
- if (lowerBit == 1){
- found++;
- }
- if (number == 0){
- break;
- }
- }
- if (found == 1){
- std::cout << "yes";
- } else {
- std::cout << "no";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement