+ 1

Another way to make the same function?

https://code.sololearn.com/csH277Maa7xn/?ref=app

22nd Sep 2021, 7:32 AM
David Romero YĂĄnez
David Romero YĂĄnez - avatar
2 Answers
0
Integer. toBinaryString() you can use Please refer the syntax through internet I can be incorrect here
22nd Sep 2021, 9:23 AM
Atul [Inactive]
0
import java.util.Scanner; //tu cĂłdigo va aquĂ­ public class Converter{ public static String toBinary(int num){ /*String binary=""; while(num>0){ binary = (num%2) + binary; num /=2; }*/ return Integer.toBinaryString(num); } } public class Program { public static void main(String[ ] args) { Scanner sc = new Scanner(System.in); int x = sc.nextInt(); System.out.print(Converter.toBinary(x)); } } //It works
22nd Sep 2021, 9:24 AM
Atul [Inactive]