| 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
 | | #! /usr/bin/env python |  |   |  | from typing import Final |  | import sys |  |   |  | n = int(sys.argv[1]) |  | power = 1 |  | LIMIT: Final[int] = n // 2 |  |   |  | # find the largest power of 2, which is less than or equal to n/2 |  | while power <= LIMIT: |  |     power *= 2 |  |   |  | binary_presentation = "" |  | while power > 0: |  |     if n < power: |  |         binary_presentation += "0" |  |     else: |  |         binary_presentation += "1" |  |         n -= power |  |     power //= 2 |  | print(binary_presentation) | 
 |