MeetCode
Nearest Power Of Two
C
C++
Computer Mathematics
CSS
DSA
HTML
Java
JavaScript
NodeJS
PHP
Programming Interview
Python
ReactJS
SQL
Run
Submit
Dark
Problem Statement
Solutions
Submissions
Nearest Power Of Two
Medium
Computer Mathematics
Integers & Divisibility
34 views
Explanation
Complexity
Problem Statement
Given n>0, print the smallest power of 2 that is >= n.
Input Format
One integer n.
Output Format
One integer.
Example
Input
9
Output
16
Constraints
1
Input / Output Format
Input Format
One integer n.
Output Format
One integer.
Constraints
1
Examples
Input:
9
Output:
16
Example Solution (Public)
Computer Mathematics
Start p=1 and keep doubling while p<n. Output p.
Official Solution Code
Wrap
Copy
Start p=1 and keep doubling while p<n. Output p.
Please
login
to submit solutions.
Editor
C
C++
Computer Mathematics
CSS
DSA
HTML
Java
JavaScript
NodeJS
PHP
Programming Interview
Python
ReactJS
SQL
Test Cases
Output
Submission Result
Input
9
Expected Output
16
Compile Output
Error
Output
Please
login
to submit solutions.