Вот питон
def tok(b, a):
s = ''
while b > 0:
e = b % a
if 0 <= e <= 9:
s = str(e) + s
else:
s = chr(ord("A") + e - 10) + s
b //= a
return s
def ink(s, k):
r = 0
for c in s:
if '0' <= c <= '9':
r = r * k + int(c)
else:
r = r * k + (ord(c) - ord('A') + 10)
return r
a = int(input())
b = input()
c = int(input())
s = ink(b,a)
print(tok(s,c)
вот что у меня получилось
}
let val,
val1,
val2;
function myFunction() {
val = document.getElementById('elem1').value;
val1 = document.getElementById('elem2').value;
val2 = document.getElementById('elem3').value;
if ((val > 0) && (val2 > 0) && (val1 > 0)){
obschet()
}
}
function obschet(){
val1 = String(val1);
var s = ink(val1,val);
alert(tok(s,val2));
}
function tok(b, a){
var s = '';
while (b > 0){
var e = b % a;
if (0 <= e <= 9){
s = String(e) + s}
else{
s = Str.fromCharCode("A".charCodeAt() + e - 10) + s;
}
b = parseInt(b/a);
}
return s;
}
function ink(s, k){
r = 0;
for (var i = 0;i < s.length;i++){
if ('0' <= s[i] <= '9'){
r = r * k + Number(s[i])}
else{
r = r * k + (s[i].charCodeAt() - 'A'.charCodeAt() + 10);
}
return r;
}