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
Zaloguj się, aby zobaczyć historię rozwiązań
Zaloguj sięZaloguj się, aby korzystać z Mentora AI
Zaloguj sięVisible tests
1
Input
0Expected
"0"2
Input
1Expected
"1"3
Input
5Expected
"101"4
Input
10Expected
"1010"5
Input
255Expected
"11111111"6
Input
256Expected
"100000000"Focus radio
Paused · SomaFM · Fluid