Skip to content

Instantly share code, notes, and snippets.

@ngsw
Created February 14, 2012 20:21
Show Gist options
  • Select an option

  • Save ngsw/1829924 to your computer and use it in GitHub Desktop.

Select an option

Save ngsw/1829924 to your computer and use it in GitHub Desktop.
#! /bin/env ruby
#-*- coding: utf-8 -*-
def fizzbuzz(n)
[*1..n].each{| i |
num = i.to_i
puts num % 15 == 0 ? "FizzBuzz" :
num % 5 == 0 ? "Buzz" :
num % 3 == 0 ? "Fizz" :
num
}
end
fizzbuzz(100)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment