Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- int main() {
- int n;
- cin >> n;
- int exponent = 0;
- for (int i = 0; i < 30; i++) {
- // find the highest power of two that can still divide 'n'
- if ((n >> i) == 1) {
- exponent = i;
- }
- }
- cout << (1 << exponent) << '\n';
- return 0;
- }
Add Comment
Please, Sign In to add comment