Skip to content

Instantly share code, notes, and snippets.

@victorhtorres
Created January 28, 2016 14:25
Show Gist options
  • Save victorhtorres/281bcf1820d9a2f25259 to your computer and use it in GitHub Desktop.
Save victorhtorres/281bcf1820d9a2f25259 to your computer and use it in GitHub Desktop.
Conversor binario recursivo
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