AlgoLounge

Binary Representation

easy

Convert a positive integer to its binary representation as a string.

Examples

Example 1

Input:  5
Output: "101"

Example 2

Input:  8
Output: "1000"

Example 3

Input:  0
Output: "0"

Constraints

  • Return binary string without "0b" prefix
  • Handle zero case specially
  • Input is non-negative integer
TypeScript
Loading editor…
List of test cases (10)
Case 1
n = 5
Case 2
n = 8
Case 3
n = 0
Case 4
n = 15
Case 5
n = 255
Case 6
n = 1
Case 7
n = 16
Case 8
n = 63
Case 9
n = 100
Case 10
n = 1024