import java.util.Scanner ;
public class Main {
public static void main ( String[] args ) {
Scanner sc = new Scanner ( System.in ) ;
int value = sc.nextInt () ; // 十進制數值
int number = sc.nextInt () ; // 要轉換的進制
Main MTool = new Main () ; // 要使用到class Main內的方法,先實體化
System.out.print ( "The base " + number + " representation of " + value + " is " ) ;
if ( value == 0 ) {
System.out.print ( "0" ) ; // 數值為「0」,則不進行轉換
}
else {
MTool.transformation ( value , number ) ; // 進行進制轉換,並輸出結果
}
System.out.println ( "." ) ;
}
// 進制轉換,並顯示數值:十進制數值、要轉換的進制
void transformation ( int value , int number ) {
// 當數值為「0」時,代表轉換結束
if ( value == 0 ) {
return ;
}
else {
transformation ( (int)(value/number), number ) ; // 在轉換結束前,不斷進行轉換
if ( value % number >= 10 ) {
// 當轉換的數值超過「10」時,必須轉換成字元
char word = (char) ( ( value % number ) - 10 + 'a' ) ;
System.out.print( word ) ;
}
else {
System.out.print ( ( value % number ) ) ; // 小於「10」直接轉換並顯示
}
}
}
}