FunctionRacerProblemsRace

Highest Power of Two

BeginnerMathPython, JavaScript, TypeScript, Java, C++

Return the largest power of 2 that is less than or equal to n.

Example 1

n 10
returns 8

8 <= 10 < 16.

Example 2

n 16
returns 16

16 itself.

Constraints

Race itor take your time

Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.

More Math problems