Binary Form
Computers store numbers in binary, using only 0 and 1. The function to_binary receives a non-negative integer n and converts it to a binary string without any extra prefix. For the number 0, return the string 0.
Примеры
Ввод
0Вывод
"0"Ввод
5Вывод
"101"Ввод
8Вывод
"1000"Нужно реализовать
def to_binary(n: int) -> str:
Теги
mathstrings
Prisijunkite, kad matytumėte pateikimų istoriją
PrisijungtiPrisijunkite, kad naudotumėte DI mentorių
PrisijungtiVisible tests
1
Input
0Expected
"0"2
Input
5Expected
"101"3
Input
8Expected
"1000"4
Input
255Expected
"11111111"5
Input
1Expected
"1"6
Input
999999Expected
"11110100001000111111"Focus radio
Paused · SomaFM · Fluid