Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Lintcode9 Fizz Buzz solution problem solution

2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/03 Report--

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

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report