Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def bases(num, base):
- basing = "0123456789ABCDEF"
- if num < base:
- return basing[num]
- else:
- return bases(num//base, base) + basing[num%base]
- test_cases = int(input())
- for why in range(test_cases):
- num = int(input())
- num = bases(num, 2)
- inc = 1
- number = 0
- n_len = len(num)
- for i in range(n_len):
- number += int(num[i]) * inc
- inc *= 2
- print(number)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement