-------------------------------------------------------------------------------------------------------------------------------------
PROGRAM mabna_m_be_n
IMPLICIT NONE
INTEGER::a,m,n,k,s1,s2,j,i,r,a10,am
PRINT*
PRINT*," (a) = (?)"
PRINT*," m n"
PRINT*
PRINT*," a ra vared konid : "
READ*,a
PRINT*
PRINT*,"mabnaye m ra vared konid : "
READ*,m
PRINT*
PRINT*,"mabnaye n ra vared konid : "
READ*,n
PRINT*
am=a
k=1
DO
IF (a<(10**k)) THEN
EXIT
ELSE
k=k+1
END IF
END DO
s1=0
DO i=0,k-1
r=MOD(a,10)
s1=s1+(r*(m**i))
a=INT(a/10)
END DO
a10=s1
s2=0
j=0
DO
IF (s1==0) THEN
EXIT
ELSE
r=MOD(s1,n)
s2=s2+(r*10**j)
j=j+1
s1=INT(s1/n)
END IF
END DO
PRINT*," (",am,") =",a10,"= (",s2,")"
PRINT*," ",m," ",n
END