If the given integer in even, recursively find half of the integer and pad it with 0 in each iteration.
If the given integer in odd, recursively find half of the integer and pad it with 1 in each iteration.
Example -
publicstatic string decimal2Binary(int n){
if(n ==0) return"0"; if(n ==1) return"1"; /* When n is even */ if(n%2==0) return decimal2Binary(n/2)+"0"; /* When n is odd */ else return decimal2Binary(n/2)+"1"; }