Decimal to Binary

· unclassifiedUnclassifiedmath

Decimal to Binary

javamay contain transcription errors
import java.util.*;
class Main{
public static void main(String[] args){
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
String binary="";
while(n>0){
binary=(n%2)+binary;
n/=2;
}
System.out.println(binary);
}
}
← Cycle Detection in Linked List (Floyd's Algorithm)Digit Sum (Repeatedly Until Single Digit) →
Report an issue with this question