Summary Files Commits Branches @commit @diff @stats
path: root / Year 1 / Programming introduction / Solutions Sem. 03 / 05. Power_Of_Two.cpp
diff options
context:
space:
mode:
1 files changed, 14 insertions, 0 deletions
-rw-r--r--Year 1/Programming introduction/Solutions Sem. 03/05. Power_Of_Two.cpp14
diff --git a/Year 1/Programming introduction/Solutions Sem. 03/05. Power_Of_Two.cpp b/Year 1/Programming introduction/Solutions Sem. 03/05. Power_Of_Two.cpp
new file mode 100644
index 0000000..0a5c88f
--- /dev/null
+++ b/Year 1/Programming introduction/Solutions Sem. 03/05. Power_Of_Two.cpp
@@ -0,0 +1,14 @@
+#include <iostream>
+
+using namespace std;
+
+int main()
+{
+ int n;
+ cin >> n;
+
+ while (n % 2 == 0 && n > 1)
+ n /= 2;
+
+ cout << ((n == 1) ? "true" : "false") << endl;
+}