Created
January 28, 2016 14:25
-
-
Save victorhtorres/281bcf1820d9a2f25259 to your computer and use it in GitHub Desktop.
Conversor binario recursivo
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 ConversorBinario { | |
public static String funcionRecursiva(int n) { | |
String cadena; | |
if (n == 0) { | |
return "0"; | |
} else { | |
return funcionRecursiva_rec(n); | |
} | |
} | |
private static String funcionRecursiva_rec(int n) { | |
String cadena; | |
if (n == 0) { | |
cadena = ""; | |
} else { | |
cadena = funcionRecursiva(n / 2) + "" + (n % 2); | |
} | |
return cadena; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment