🎨
CMMobileBook
  • CMoney Mobile Book
  • Git主題
    • Git 基本知識
    • Git 使用方法
    • Git Flow 開發方式
    • Commit Message 規則
    • GitLab + SSH key
    • 相關學習網站
    • 延伸 Bitbucket 操作
  • Scrum主題
    • Scrum 基本知識
  • 程式練習題
    • 前言
    • 物件導向練習
      • StopWatch
    • Foundation 程式練習
      • 合法回文-1 Valid Palindrome
      • Reformat Date
      • Day of the Year
      • Peak Index in a Mountain Array
      • Number of Days Between Two Dates
      • To lower case
      • Two Sum
      • Best Time to Buy and Sell Stock
      • Best Time to Buy and Sell Stock II
    • 條件邏輯練習
      • FizzBuzz
      • Single Number
      • Self Dividing Number
Powered by GitBook
On this page

Was this helpful?

  1. 程式練習題
  2. 條件邏輯練習

FizzBuzz

Previous條件邏輯練習NextSingle Number

Last updated 4 years ago

Was this helpful?

Write a program that outputs the string representation of numbers from 1 to n.

But for multiples of three it should output “Fizz” instead of the number and for the multiples of five output “Buzz”. For numbers which are multiples of both three and five output “FizzBuzz”.

Example:

n = 15,

Return:
[
    "1",
    "2",
    "Fizz",
    "4",
    "Buzz",
    "Fizz",
    "7",
    "8",
    "Fizz",
    "Buzz",
    "11",
    "Fizz",
    "13",
    "14",
    "FizzBuzz"
]
FizzBuzz 題目
Loading...LeetCode
Logo