We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
FEAT
1 parent 3dceff6 commit 4dd378eCopy full SHA for 4dd378e
src/PracticeAlgorithms.java
@@ -7,13 +7,13 @@ public static String toBinaryString(int x) {
7
StringBuilder binaryString = new StringBuilder();
8
binaryString.append(binaryFormString(x, binaryString.toString()));
9
10
- return binaryString.reverse().toString();
+ return binaryString.toString();
11
}
12
13
private static String binaryFormString(int x, String binString) {
14
if (x == 1) return binString + "1";
15
16
- return (x % 2) + binaryFormString(x / 2, binString);
+ return binaryFormString(x / 2, binString) + (x % 2);
17
18
19
public static void main(String[] args) {
@@ -22,6 +22,6 @@ public static void main(String[] args) {
22
23
System.out.println(isBetweenZeroAndOne(testX, testY));
24
25
- System.out.println(toBinaryString(7));
+ System.out.println(toBinaryString(8));
26
27
AltStyle によって変換されたページ (->オリジナル) / アドレス: モード: デフォルト 音声ブラウザ ルビ付き 配色反転 文字拡大 モバイル
0 commit comments