Coder Social home page Coder Social logo

fizz-buzz's Introduction

fizz-buzz game

基本需求

写一个程序打印1到100这些数字:

  • 但是遇到数字为3的倍数的时候,打印“Fizz”替代数字,
  • 5的倍数用“Buzz”代替,
  • 既是3的倍数又是5的倍数打印“FizzBuzz”。

扩展需求

遇到包含3的数字打印“Fizz” 遇到包含5的数字打印“Buzz” 如果既包含3,又包含5时,打印"FizzBuzz"

需求澄清

既是3的倍数又是5的倍数打印“fizzbuzz.FizzBuzz”。 如果既包含3,又包含5时,打印"fizzbuzz.FizzBuzz"

如果被3包含,又被5整除时,打印什么呢? 打印"fizzbuzz.FizzBuzz"

即两个需求结合:

如果是3的倍数或者包含3,又是5的倍数或者包含5时,打印"fizzbuzz.FizzBuzz"

测试用例:


基本需求:

Input  1,2  =>  “1”,”2”

input  3,9  =>   Fizz

Input  5,10,20 => Buzz

Input   15 =>  fizzbuzz.FizzBuzz


扩展需求:

input  13,31 => Fizz

Input  52  => Buzz

同时包含3,包含5 
input  35 => fizzbuzz.FizzBuzz

包含3 ,被5整除
input  305  => fizzbuzz.FizzBuzz

被3整除,包含5
input   51  => fizzbuzz.FizzBuzz





Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.