Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR RUBY

ruby negative indices fizz buzz

# Rosettacode.org has this excellent one-line FizzBuzz solution in Ruby.
# It works because Ruby allows negative indices.

1.upto(100){|n|puts'FizzBuzz '[i=n**4%-15,i+13]||n}
 
PREVIOUS NEXT
Tagged: #ruby #negative #indices #fizz #buzz
ADD COMMENT
Topic
Name
8+3 =