Notice
Recent Posts
Recent Comments
Link
코드로 우주평화
Binary Addition 본문
반응형
Description:
Implement a function that adds two numbers together and returns their sum in binary. The conversion can be done before, or after the addition.
The binary number returned should be a string.
Examples:(Input1, Input2 --> Output (explanation)))
1, 1 --> "10" (1 + 1 = 2 in decimal or 10 in binary)
5, 9 --> "1110" (5 + 9 = 14 in decimal or 1110 in binary)
Solution:
1. Add 'a' and 'b'.
2. Find the binary number of the added value.
function addBinary(a,b){
return (a+b).toString(2)
}
반응형
'나는 이렇게 학습한다 > Algorithm & SQL' 카테고리의 다른 글
Counting Duplicates (0) | 2022.03.01 |
---|---|
Growth of a Population (0) | 2022.03.01 |
Unique In Order (0) | 2022.02.26 |
Find the next perfect square! (0) | 2022.02.25 |
Exes and Ohs (0) | 2022.02.24 |