Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

check if number is power of 2 python

def is_power_of_two(number : int) -> bool:
    while number != 1:
        if number % 2:
            return False
        number /= 2
    return True
 
PREVIOUS NEXT
Tagged: #check #number #power #python
ADD COMMENT
Topic
Name
5+3 =