Problems > Largest Power of Two Within

Largest Power of Two Within

Difficulty: 900 2000 ms 128 MB

math bitwise

Print the largest power of two that is ≤ N.

Input: one integer N.

Output: 2 to the power ⌊log₂ N⌋.

Constraints:

  • 1 ≤ N ≤ 1018

Sample Tests

Input 1
20
Output 1
16
Input 2
64
Output 2
64

Read the Editorial

Discussion (opens after you solve — no spoilers before)

No comments yet.

Submit Your Solution

Log in or create a free account to run and submit code.