DEV Community

Discussion on: Daily Challenge #134 - Rice and Chessboard Problem

Collapse
 
diegoehg profile image
Diego Hdez

Using bit shifting in Python:

def calculate_squares(x):
    if x == 0:
        return 0
    return 1 + calculate_squares(x >> 1)