raj

mail@pastecode.io avatar
unknown
python
2 years ago
366 B
2
Indexable
Never
def stairs_game(stairs_num):
    result = 0
    if stairs_num == 0 or stairs_num == 1:
        return stairs_num
    while stairs_num != 0:
        if stairs_num % 2:
            stairs_num -= 1
        else:
            stairs_num //= 2
        result += 1
    return result

stairs = int(input("Enter number of stairs: "))
print(stairs_game(stairs))