[solution] quizz 126

P

philip

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) }
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top