I need a FizzBuzz question that is not related to the modulo operator. Moreover, I usually interview web developers for whom the modulo operator just doesn’t arise so often. And if this is not what you encounter regularly, this is one of those things that you look at several times when you need it.
(Of course, this is a concept that, ideally, should have been found in a mathematical course somewhere along the way, but this is a different topic.)
So, I came up with what I call, unimaginably, Threes in Reverse . Instruction:
Write a program that issues in the reverse order, each multiple of 3 from 1 to 200.
Doing this in the usual way is easy: multiply the loop index by 3 until you reach a number greater than 200, and then close. You do not need to worry about how many iterations will stop after, you just keep going until you reach too high a value.
But going back, you need to know where to start. Some may intuitively understand that 198 (3 * 66) is the highest multiple of 3, and as such, hard code 66 per loop. Others may use a mathematical operation (integer division or gender () for 200 and 3 floating point division) to figure out this number and still provide something more general applicable.
In fact, this is the same problem as FizzBuzz (switching values and printing them using a twist). This is one of the problems for the solution, which does not use anything as (relatively) esoteric as the modulo operation.
Legion Oct 25 2018-10-10 at 10:56
source share