decimal number to binary in java using recursion

Solutions on MaxInterview for decimal number to binary in java using recursion by the best coders in the world

showing results for - "decimal number to binary in java using recursion"
Nathan
03 Nov 2019
1public class DecimalToBinaryUsingRecursion
2{
3   public static void main(String[] args)
4   {
5      int inputDecimal = 50;
6      System.out.println(toBinary(inputDecimal));
7   }
8   static int toBinary(int decimal)
9   {
10      if(decimal == 0)
11         return 0;
12      else
13         return(decimal % 2 + 10 * toBinary(decimal / 2));
14   }
15}