bt3gl a85ed914d3 👾
2023-07-30 21:40:09 -07:00

15 lines
272 B
Python

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# author: bt3gl
def reverse_bits(n: int) -> int:
result, base = 0, 31
while n:
result += (n & 1) << base
n >>= 1
base -= 1
return result