Skip to content

Instantly share code, notes, and snippets.

@drbrain
Last active June 23, 2016 22:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save drbrain/94c38425fdf3ef92f03c38920d932083 to your computer and use it in GitHub Desktop.
Save drbrain/94c38425fdf3ef92f03c38920d932083 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
numbers = (1..100).to_a
numbers.each do |n|
div_5 = n.divmod(5).last.zero?
div_7 = n.divmod(7).last.zero?
message =
if div_5 and div_7 then
"foo"
elsif div_7 then
"baz"
elsif div_5 then
"bar"
else
n
end
puts message
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment