4 ms·
Maybe I’m missing something but can’t you unroll it very easily by 15 prints at a time? That would skip the modulo checks entirely, and you could actually cache
by hyperhello 1y ago
Maybe I’m missing something but can’t you unroll it very easily by 15 prints at a time? That would skip the modulo checks entirely, and you could actually cache everything but the last two or three digits.
- Terretta 1y ago> Maybe I’m missing something but can’t you unroll it very easily by 15... Sure, 3 x 5 = 15. But, FTA: But then, by coincidence, I watched an old Prime video and decided to put the question to him: how would you extend this to 7 = "Baz"? He expanded the if-else chain: I asked him to find a way to do it without explosively increasing the number of necessary checks with each new term added. After some hints and more discussion... Which is why I respectfully submit almost all examples of FizzBuzz including the article's first are "wrong" while the refactor is "right". As for the optimizations, they don't focus on only 3 and 5, they include 7 throughout.