Hausaufgabe-10-11/IntToBinary.java
Sobottasgithub 52b14b6ad2 Fixup
2025-11-12 17:05:20 +01:00

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);
}
}
}