Title Description: give you an integer n. From 1 to n print each number according to the following rules:
If this number is divisible by 3, print fizz.
If this number is divisible by 5, print buzz.
If this number can be divisible by 3 and 5 at the same time, print fizz buzz.
Example: for example, n = 15, returns an array of strings:
[
"1", "2", "Fizz",
"4", "Buzz", "Fizz",
"7", "8", "Fizz",
"Buzz", "one by One", "Fizz",
"+", "Fizz Buzz"
]
Lintcode The simplest of topics, not to speak, put the code here:
Class solution: "" " @param n:an integer as Description @return: A List of strings. For example, if n = 7, your code should return ["1", "2", "Fizz", "4", "Buzz", "Fizz", "7"] "" " def Fizzbuzz (s Elf, N): results = [] for I in range (1, n+1): if i% = = 0: results.append ("Fizz Buzz") elif i% 5 = = 0: results.append ("Buzz") elif I% 3 = = 0: results.append ("fizz") else: results.append ( STR (i)) return results
Fizz Buzz Question