CLS
INPUT "vvedite chislo"; a$
INPUT "vvedite q"; q
INPUT "vvedite p"; p
DIM c(LEN(a$))
u$ = "0123456789ABCDEF"
FOR i = 1 TO LEN(a$): FOR j = 1 TO LEN(u$)
IF UCASE$(MID$(a$, i, 1)) = MID$(u$, j, 1) THEN c(i) = j - 1
NEXT: NEXT
FOR i = LEN(a$) TO 1 STEP -1
b = b + c(i) * q ^ r
r = r + 1
NEXT
DO
c$ = MID$(u$, (b MOD p) + 1, 1) + c$
b = b \ p
LOOP UNTIL b = 0
PRINT STRING$(80, 196)
PRINT c$
Тестирование выполнено в программе QB64 ( Скачать )