Dsa
Math
Easy
Consecutive Powers
Given a positive integer n, find the largest integer k such that 2^k is less than or equal to n.
Input Format:
A single line containing the integer n (1 <= n <= 10^9).
Output Format:
A single line with the integer k.
Example:
Input:
20
Output:
4
(2^4 = 16 which is the largest power of 2 less than 20)
Key concepts
mathpowersconsecutive
Practise this out loud — free
Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.
🎙 Practise this question now