14 lines
371 B
Java
14 lines
371 B
Java
public class IntToBinary {
|
|
// !!!!! DER REST DER AUFGABE IST IN DER README.md BEANTWORTED !!!!!
|
|
// BITTE Main.java MIT BEACHTEN !!!!!!!!!!
|
|
|
|
public String binary(int n) {
|
|
if (n <= 1) {
|
|
return "" + n;
|
|
} else {
|
|
// Prevent adding the numbers by converting to String and convert it back to int after
|
|
return binary(n / 2) + (n % 2);
|
|
}
|
|
}
|
|
}
|