Quizz 126

Hi,
here is the one i came up with:

------first-----------------------------

c=100

def chaos_coop x
a1,a2 = (x % 3 == 0) ? [“Fizz”,“Fizz”] : ["",x]
(x % 5 == 0) ? a1 +“Buzz” : a2
end

(1…c).each {|x|
puts chaos_coop(x) }

-----second-----------------------------------

c=100
def square_coop x
a3=(x % 3 == 0) ? 1 : 0
a5=(x % 5 == 0) ? 2 : 0

case a3+a5
when 0 : x
when 1 : “Fizz”
when 2 : “Buzz”
when 3 : “FizzBuzz”
end
end

(1…c).each {|x|
puts square_coop(x) }

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs