Created
September 16, 2022 16:37
-
-
Save adeleke5140/5e7b6fc30f1683edfb1036231c72e1f5 to your computer and use it in GitHub Desktop.
Convert decimal to Binary recursively
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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