Skip to content

Instantly share code, notes, and snippets.

@adeleke5140
Created September 16, 2022 16:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adeleke5140/5e7b6fc30f1683edfb1036231c72e1f5 to your computer and use it in GitHub Desktop.
Save adeleke5140/5e7b6fc30f1683edfb1036231c72e1f5 to your computer and use it in GitHub Desktop.
Convert decimal to Binary recursively
public class DecimalToBinary{
public state void main(String[] args){
String binary = findBinary(233, "");
}
public state String findBinary(int decimal, String result){
if(decimal == 0){
return result;
}
result = decimal % 2 + result;
return findBinary(decimal / 2, result);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment