Skip to content

FizzBuzz

Python loop + multiple conditions

Flowchart (ISO 5807)

YesNoYesNoYesNoStartInput ni = 1, n, 1i mod 15 = 0Output «FizzBuzz»i mod 3 = 0Output «Fizz»i mod 5 = 0Output «Buzz»Output iEndFigure 1 — fizzbuzz

Source code

Python
def fizzbuzz(n):
    for i in range(1, n + 1):
        if i % 15 == 0:
            print("FizzBuzz")
        elif i % 3 == 0:
            print("Fizz")
        elif i % 5 == 0:
            print("Buzz")
        else:
            print(i)

The editor opens with this code — change it and the chart redraws.

Language
Python
Constructs
loop + multiple conditions
Topic
Algorithms
Formats
Word, Visio, draw.io, PDF, SVG

Related examples