FizzBuzz Rules
FizzBuzz is a classic way to practice conditions, especially the order of checks. The function fizzbuzz receives a number n and returns FizzBuzz if it is divisible by 15, Fizz if it is divisible by 3, and Buzz if it is divisible by 5. If none of these rules match, return the number itself as a string.
Примеры
Ввод
15Вывод
"FizzBuzz"Ввод
3Вывод
"Fizz"Ввод
5Вывод
"Buzz"Нужно реализовать
def fizzbuzz(n: int) -> str:
Теги
mathstrings
Pieslēdzies, lai redzētu iesniegumu vēsturi
PieslēgtiesPieslēdzies, lai izmantotu AI mentoru
PieslēgtiesVisible tests
1
Input
15Expected
"FizzBuzz"2
Input
3Expected
"Fizz"3
Input
5Expected
"Buzz"4
Input
7Expected
"7"5
Input
30Expected
"FizzBuzz"6
Input
-100Expected
"Buzz"Focus radio
Paused · SomaFM · Fluid