Skip to content

Instantly share code, notes, and snippets.

(1..100).each{|i|
x = ''
x += 'Fizz' if i%3==0
x += 'Buzz' if i%5==0
puts(x.empty? ? i : x);
}
fizzbuzzes = (1..100).to_a.map do |i|
if i % 15 == 0 then "fizzbuzz"
elsif i % 3 == 0 then "fizz"
elsif i % 5 == 0 then "buzz"
else i
end
end
puts fizzbuzzes