Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* самостоятельно напишите код, требуемый по условию задачи */
- #include <iostream>
- using namespace std;
- bool IsPowOfTwo(int num){
- if(num <= 0){
- return false;
- }
- if(num == 1){
- return true;
- }else if(num % 2 == 0){
- return IsPowOfTwo(num/2);
- }
- return false;
- }
- int main() {
- int result = IsPowOfTwo(1024);
- cout << result << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment