Number to binary converter
Problem to convert the number to binary.
Example-1:
Input : n = 5 Output : "101" Explain : 5 binary value is "101".
Example-2:
Input : n = 8 Output : "1000" Explain : 8 binary value is "1000".
Solution
public class Main { public static void main(String [] args) { int n = 2; System.out.print(Integer.toBinaryString(n)); } }
n = 2 a = bin(n) print(a[2:])
Output
10