“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”.”
elsework, as well. It’s probably what you expected. Go ahead and try to refactor this into a one-liner.
div_by_fifteenmethods. They should work the same way, but this will let you get practice actually writing it out. Once you see this, you’re ready to advance:
crystal build src/fizzbuzz.cr && ./fizzbuzzyou should see
numprinted 100 times. Note that our tests didn’t actually run. Not only are they not run, they’re actually not even in the executable:
ifreturns a value, we could also do something like this:
(1..100).each, to make
numgo from 1 to 100 instead of from 0 to 99.