fizzbuzz in ruby

#!/usr/bin/env ruby

(1..100).each do |num|
  three = (num % 3 == 0)
  five = (num % 5 == 0)
  print 'fizz' if three
  print 'buzz' if five
  print num if (!three and !five)
  puts
end

Comments

Popular posts from this blog

Openvpn and unbound combined break dig command

Stress Linux system: stress-ng

Google Nexus 4: permanent back panel glass repair for less than a penny