Skip to content

Instantly share code, notes, and snippets.

@itskingori
Created March 25, 2014 12:10
Show Gist options
  • Save itskingori/9760562 to your computer and use it in GitHub Desktop.
Save itskingori/9760562 to your computer and use it in GitHub Desktop.
Outputs each number from 1 to 100, however … when the number is a multiple of 3 print WAKKA instead of that number. When the number is a multiple of 5, print WAAAA instead of that number. For numbers which are multiples of 3 AND 5, print WAKKAWAAAA.
#!/usr/bin/env ruby
(1..100).each { |n|
puts n unless( n%3 == 0 || n%5 == 0)
puts 'WAKKA' if (n%3 == 0 && n%5 != 0)
puts 'WAAAA' if (n%5 == 0 && n%3 != 0)
puts 'WAKKAWAAAA' if (n%3 == 0 && n%5 == 0)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment