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 i in range(test_cases):
- number_and_base = input().split(" ")
- number = int(number_and_base[0])
- base = int(number_and_base[1])
- base_num = bases(number, base)
- print(base_num)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement