Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

Lintcode9 Fizz Buzz solution problem solution

Shulou Source: shulou.com Published: 2022-06-03 04:34:54 10月03日 Update

[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/

Tags: At the same time skills skills integers answers rules questions face-to-face problem solutions. Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MariaDB Shulou Technology OPPO Reno NVidia Docker