Lintcode9 Fizz Buzz solution problem solution
[topic description]
Given number n. Print number from 1 to n. But:
When number is divided by 3, print "fizz".
When number is divided by 5, print "buzz".
When number is divided by both 3 and 5, print "fizz buzz".
I'll give you an integer n. Print each number from 1 to n 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 is divisible by both 3 and 5, print fizz buzz.
[topic link]
Http://www.lintcode.com/en/problem/fizz-buzz/
[topic Analysis]
The problem is too simple. The trick is to judge that the skill is divisible by 3 and 5, and then judge separately.
[answer link]
Http://www.jiuzhang.com/solutions/fizz-buzz/