FizzBuzz

This famous exercise helps you practice conditions and the order of checks. Write a function fizzbuzz that takes a number n and returns a string by these rules: if the number is divisible by 15, return FizzBuzz; if it is divisible only by 3, return Fizz; if it is divisible only by 5, return Buzz. If none of the rules match, return the number itself as a string.

Примеры

Ввод
1
Вывод
"1"
Ввод
3
Вывод
"Fizz"
Ввод
15
Вывод
"FizzBuzz"

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

def fizzbuzz(n: int) -> str:

Теги

stringsmath
PostgreSQLv16

Le résultat de l'exécution du code s'affichera ici

Visible tests
1
Input
1
Expected"1"
2
Input
3
Expected"Fizz"
3
Input
5
Expected"Buzz"
4
Input
15
Expected"FizzBuzz"
5
Input
7
Expected"7"
6
Input
30
Expected"FizzBuzz"
Focus radio
Paused · SomaFM · Fluid