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)


  1. Finding the time and actual effort to create a superb article like this is great thing. I’ll learn many new stuff right here! Good luck for the next post buddy..
    AWS Training in Chennai


Post a Comment

Popular posts from this blog

Debugging pfsense firewall rules clearly and easily

Direct ssh to a server via proxy using putty/plink on Windows

telnet vs netcat