Binary Form

Binary notation writes a number using only 0 and 1, which is how data is ultimately stored and processed by computers. Write a function to_binary that converts a non-negative integer n into a binary string with no leading zeros. For 0, return the string 0.

Примеры

Ввод
0
Вывод
"0"
Ввод
1
Вывод
"1"
Ввод
5
Вывод
"101"

Нужно реализовать

def to_binary(n: int) -> str:

Теги

mathstrings
PostgreSQLv16

Aici va apărea rezultatul execuției codului

Visible tests
1
Input
0
Expected"0"
2
Input
1
Expected"1"
3
Input
5
Expected"101"
4
Input
10
Expected"1010"
5
Input
255
Expected"11111111"
6
Input
256
Expected"100000000"
Focus radio
Paused · SomaFM · Fluid