# Solution to 126

**URL:** <https://www.ruby-forum.com/t/solution-to-126/105925>\
**Category:** Ruby\
**Created:** [June 4, 2007, 6:40pm UTC](https://www.ruby-forum.com/t/solution-to-126/105925 "2007-06-04T18:40:07Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Justin\_E](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/a88e57/32.png) [@Justin\_E](https://www.ruby-forum.com/u/Justin_E)\
**Post date:** [June 4, 2007, 6:40pm UTC](https://www.ruby-forum.com/t/solution-to-126/105925/1 "2007-06-04T18:40:07Z")

</div>

Hello,

Here is my solution. I made the assumption that the interviewer has a  
terminal handy and I have 5-10 minutes to crank this out. If I was just  
writing it down on paper, I made a note of a couple things that I got  
wrong  
before I had a chance to see the output:

for i in 1…101 # was 100 before checking this  
out = ‘’  
out = out + ‘Fizz’ if (i % 3) == 0  
out = out + ‘Buzz’ if (i % 5) == 0  
out = i.to\_s if (out.size) == 0

print out + “\n” # Original did not have a newline  
end

Thanks,

Justin
