Decimal to Binary


Submit solution

Points: 10 (partial)
Time limit: 1.0s
Memory limit: 64M

Authors:
Problem type
Allowed languages
Java 19, Java 8

題目說明

輸入一個十進制的正整數,輸出它的二進制表示。

轉換步驟(以 13 為例)

步驟 除以2的結果
13 ÷ 2 = 6 餘 1
6 ÷ 2 = 3 餘 0
3 ÷ 2 = 1 餘 1
1 ÷ 2 = 0 餘 1

倒序排列餘數:
13(₁₀) = 1101(₂)

輸入

正整數。

輸出

輸出該數的二進制表示(不含前導零)。

sample input1

13

sample output1

1101

sample input2

8

sample output2

1000

Comments

There are no comments at the moment.