File size: 146 Bytes
b2dd9e4
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11

def next_power_of_2(n): 
  if n and not n & (n - 1):
    return n

  count = 0
  while n != 0: 
    n >>= 1
    count += 1

  return 1 << count;