/* input = 11
output = 1011
*/
import java.io.*;
import java.util.Scanner;
class GFG {
public static void main (String[] args) {
//System.out.println("GfG!");
Scanner scan = new Scanner(System.in);
int decimalNumber = scan.nextInt();
String binary = "";
while(decimalNumber>0){
binary += Integer.toString(decimalNumber%2);
decimalNumber = decimalNumber/2;
}
StringBuffer sb = new StringBuffer(binary);
System.out.println(sb.reverse());
}
}
output = 1011
*/
import java.io.*;
import java.util.Scanner;
class GFG {
public static void main (String[] args) {
//System.out.println("GfG!");
Scanner scan = new Scanner(System.in);
int decimalNumber = scan.nextInt();
String binary = "";
while(decimalNumber>0){
binary += Integer.toString(decimalNumber%2);
decimalNumber = decimalNumber/2;
}
StringBuffer sb = new StringBuffer(binary);
System.out.println(sb.reverse());
}
}
No comments:
Post a Comment