54. Decimal to Binary

Acceptance — 0 accepted 0 submissions

Easy
LoopsMathStrings
No companies listed
Now let's go the other way. Convert a normal decimal number into binary.

Keep dividing by 2 and note the remainders. Reading the remainders from bottom to top gives the binary form.

Input Format
A single integer n.

Output Format
Print the binary representation of n without leading zeros. For 0 print 0.

Constraints
• 0 ≤ n ≤ 10^9

Example 1

Input
11
Output
1011

Explanation 11 → 1, 5 → 1, 2 → 0, 1 → 1. Reversed: 1011.

Example 2

Input
0
Output
0

Explanation Zero stays 0.

Example 3

Input
8
Output
1000

Explanation 8 is a power of two: 1000.

Acceptance —
Accepted 0
Submissions 0
Auto-save
Saved Ln 1, Col 1
Submit a solution to see its status here.
Input
Expected Output
1011
No results yet
Run your code to test it against the sample cases.
Problem List