9的二进制为1001
1+0x2+0x2x2+0x2x2x2=9
9/2=4….1
4/2=2….0
2/2=1…..0
1/2=0…..1
所以9的二进制就为从下往上的余数1001
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int A= in.nextInt();
int B=in.nextInt();
transform(A,B);
}
}
public void transform(int A,int B){
if(A/B==0)
System.out.print(A);
}else{
transform(A/B,B);
s=A%B;
System.out.print(s);
}