FizzBuzz
This page needs a recent browser (with SharedArrayBuffer support). Please update Chrome, Edge, Firefox or Safari to the latest version. · このページには最新のブラウザ(SharedArrayBuffer対応)が必要です。Chrome、Edge、Firefox、Safariを最新バージョンに更新してください。
This one builds on a lesson you haven't finished yet. Do that lesson first: · これはまだ完了していないレッスンの先にある内容です。まずはそのレッスンを済ませてください:
Python Basics · Functions →
English
FizzBuzz
The classic. Walk the numbers 1 to n and, for each, decide what string to add to a list:
- divisible by both 3 and 5 →
FizzBuzz - divisible by 3 →
Fizz - divisible by 5 →
Buzz - otherwise → the number itself, as a string
Check the "both" case first, or a multiple of 15 will be caught by the 3 test alone.
日本語
FizzBuzz
古典的な問題です。1 から n までの数を巡り、それぞれに対してリストに追加する文字列を決定します:
- 3でも5でも割り切れる →
FizzBuzz - 3で割り切れる →
Fizz - 5で割り切れる →
Buzz - その他 → 数字自体を文字列として
「両方」の場合を最初にチェック不然、15の倍数は3で割れるテストだけで判定されてしまいます。
Write fizzbuzz(n) returning a list for the numbers 1..n: Fizz if divisible by 3, Buzz if by 5, FizzBuzz if by both, otherwise the number as a string. · fizzbuzz(n) を書いて、1..n の数字に対するリストを返してください:3で割れるなら Fizz、5で割れるなら Buzz、両方で割れるなら FizzBuzz、_pageable否则数字を文字列として返す。
Click Run to see the output here. · 実行ボタンをクリックして出力を確認してください。