Skip to content

Instantly share code, notes, and snippets.

@ahmgeek
Created June 3, 2016 23:29
Show Gist options
  • Save ahmgeek/93925ccf8ab195d0e50515f3db2c07d0 to your computer and use it in GitHub Desktop.
Save ahmgeek/93925ccf8ab195d0e50515f3db2c07d0 to your computer and use it in GitHub Desktop.
Code CracklePop
module Divisable
def divided_by?(num, divisor)
num % divisor == 0
end
end
class CracklePop
include Divisable
def initialize
@num = (1..100).to_a
end
def execute
@num.each do |n|
puts "Crackle" if divided_by?(n, 3)
puts "Pop" if divided_by?(n, 5)
puts "CracklePop" if divided_by?(n, 5) && divided_by?(n, 3)
puts n
end
end
end
cp = CracklePop.new
cp.execute
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment