3 ms·
You can even implement FizzBuzz without being aware of the modulo operator. It's not that hard to write your own test that does the same thing.
by mcv 12y ago
You can even implement FizzBuzz without being aware of the modulo operator. It's not that hard to write your own test that does the same thing.
- JoeAltmaier 12y agoSure you could have two counters, one initialized to 3 and one to 5, that are decremented each time thru the loop. When they reach zero print Fizz or Buzz and reinitialize. Or you could create a finite list, initialize each member to its index, then go through by 3's and 5's and replace a number with Fizz or Buzz, or if not a number just add it. Or you could create a program that generates print statements that print the same, then run that. Or you could write a scraper that searches the web for 'fizzbuzz solution' and print the text on that page. Or...
- mcv 12y agoOr you take the number, divide it by 3, round down, multiply by 3, and if it's the same as the original, you print Fizz. Same effect as the modulo operator, but without the modulo operator.