id/email
password
forgot password | create account
about | help | code help+videos | done | prefs
CodingBat code practice

 

nextPowerOf2


The powers of two are 1, 2, 4, 8, 16, 32, 64, and so on. Given a positive integer, find the smallest power of 2 that is greater than or equal to that integer.


nextPowerOf2(47) → 64
nextPowerOf2(18) → 32
nextPowerOf2(31) → 32

...Save, Compile, Run (ctrl-enter)

int nextPowerOf2(int num) { }

Editor font size %:
Shorter output


Forget It! -- delete my code for this problem

Progress graphs:
 Your progress graph for this problem
 Random user progress graph for this problem
 Random Epic Progress Graph

Java Help

Misc Code Practice

Difficulty: 120

Copyright Nick Parlante 2017 - privacy