Advertisement
Guest User

Bruce can't Convert

a guest
Aug 21st, 2019
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.41 KB | None | 0 0
  1. def bases(num, base):
  2.     basing = "0123456789ABCDEF"
  3.    
  4.     if num < base:
  5.         return basing[num]
  6.     else:
  7.         return bases(num//base, base) + basing[num%base]
  8.  
  9. test_cases = int(input())
  10.  
  11. for i in range(test_cases):
  12.     number_and_base = input().split(" ")
  13.     number = int(number_and_base[0])
  14.     base = int(number_and_base[1])
  15.    
  16.     base_num = bases(number, base)
  17.    
  18.     print(base_num)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement