summaryrefslogtreecommitdiffstats
path: root/fizzbuzz.py
blob: 82d632c90a7310cb05365683f33e49492789fb4c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
"""
problem: write program that prints the numbers from 1 to 100 and for any multiples of 3 print "Fizz",
for any multiple of 5 print "Buzz", and for any multiple of both 3 and 5 print "FizzBuzz"

solution: use an  if elseif elseif else  statement starting with most specific case: the 3 and 5 multiple
"""
def fizzbuzz(n):
    for i in range(1, n):
        if i % 3 == 0 and i % 5 == 0:
            print("FizzBuzz")
        elif i % 3 == 0:
            print("Fizz")
        elif i % 5 == 0:
            print("Buzz")
        else:
            print(i)

def main():
    n = 100
    fizzbuzz(n)

if __name__ == "__main__":
    main()