Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def TenToP(n,p):
- res = ''
- while n >= p:
- res = str(n % p) + res
- n = n // p
- res = str(n) + res
- return res
- def ToTen(n,p):
- res = 0
- i = 0
- while n:
- res += (n % 10) * p**i
- i += 1
- n = n // 10
- return res
- q = int(input())
- p = int(input())
- n = int(input())
- print(TenToP(ToTen(n,p),q))
- n = int(input())
- print(TenToP(ToTen(n,q),p))
Advertisement
Add Comment
Please, Sign In to add comment