Loops

Fizzbuzz

Imported from the upstream Vibescript examples at loops/fizzbuzz.vibe and runnable in the browser today.

Reference View source
Source loops/fizzbuzz.vibe
# vibe: 0.2

def fizzbuzz(limit)
  output = ""
  for n in 1..limit
    if n % 15 == 0
      output = output + "FizzBuzz\n"
    elsif n % 3 == 0
      output = output + "Fizz\n"
    elsif n % 5 == 0
      output = output + "Buzz\n"
    else
      output = output + n
      output = output + "\n"
    end
  end
  output
end

def run
  fizzbuzz(20)
end
Output
Press run to execute run from this example.
upstream loops browser-runner