Skip to content

Instantly share code, notes, and snippets.

@ismaelnoble
Created September 24, 2017 15:37
Show Gist options
  • Select an option

  • Save ismaelnoble/3b9a95047ea306124ac4ba771c83f2a8 to your computer and use it in GitHub Desktop.

Select an option

Save ismaelnoble/3b9a95047ea306124ac4ba771c83f2a8 to your computer and use it in GitHub Desktop.
buzzier fizzbuzz v1.1
def checkem(value) #
if (value % 3).zero? && (value % 5).zero?
'FizzBuzz'
elsif (value % 5).zero?
'Buzz'
elsif (value % 3).zero?
'Fizz'
else
value
end
end
def fizzbuzz(limit, &additionalwork) # get list and print out fizz buzzez
numbers = [*1..limit]
numbers.map! { |num| checkem(num) }
numbers.each(&additionalwork) if additionalwork
numbers
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment