In my solution I used next because when I tried it not using next it kept printing 0, so I used the code on line 1 and it omitted it. The code on line 4 says that if i has no reminder when divided by 3 and 5 it should print "fizzbuzz". I wrote the code on the bottom at first but because the other two conditions were already met it didn't work. Once I changed the order it worked.
The solution above I got from gist. This solution differs from mine. This solution uses a .each iterator and it puts the whole code in one block. Also this solution using 15 instead of 3 and 5.
No comments:
Post a Comment