index | submit | rank | book

dec2bin – Decimal do binary

Write a program that converts decimal numbers to binary, i.e., from base 10 to base 2.

Input will consist of several lines each with a decimal number d of up to 9 decimal digits.

For each line of input, output should contain a line with the binary representation of the corresponding input number.

Example Input

1
2
3
18
8

Example Output

1
10
11
10010
1000

Scoring

Submit your solution to be graded according to the following list:

Hints

Remember the characters '0' and '1' are different than the numeric values 0 and 1. You can create a function which converts between both by using an if or case expression.

try first: digit-palindrome

try also: bin2dec

try next: dec2hex

index | submit | rank | book

Copyright © 2020-2021 Rudy Matela
All rights reserved