fizz buzz code example

Example 1: fizz buzz python

def fizz_buzz(input):
    if (input % 3 == 0) and (input % 5 == 0):
        return "FizzBuzz"
    if input % 3 == 0:
        return "Fizz"
    if input % 5 == 0:
        return "Buzz"
    else:
        return input


print(fizz_buzz(3))

Example 2: FizzBuzz

for (let i = 1, msg; i <= 100; i++, msg = '') {
  if (!(i % 3)) msg += 'Fizz';
  if (!(i % 5)) msg += 'Buzz';
  console.log(msg || i);
}

Example 3: fizz buzz python

#made by myself :)
def FizzBuzz() :
    Numbers = 0
    for Numbers in range(101):
        if Numbers%3 == 0:
            print ("Fizz")
        if Numbers%5 == 0:
            print ("Buzz")
        if Numbers%3 == 0 and Numbers%5 ==0:
            print ("Fizz Buzz")
        else :
            print (Numbers)
FizzBuzz()

Tags:

Java Example