On 5/11/07, Emmanuel Oga <[EMAIL PROTECTED]> wrote:
> Escriban un programa que haga lo siguiente:
>
> "Write a program that prints the numbers from 1 to 100. But for multiples of 
> three print "Fizz" instead of the number and for the multiples of five print 
> "Buzz". For numbers which are multiples of both three and five print 
> "FizzBuzz"."
>

1.upto(100) do |n|
  print "Fizz" if a = (n % 3).zero?
  print "Buzz" if b = (n % 5).zero?
  print n unless (a || b)
  print "\n"
end

-- 
Michel
_______________________________________________
ruby mailing list
[email protected]
http://lista.rubyargentina.com.ar/listinfo.cgi/ruby-rubyargentina.com.ar

Responder a