logoalt Hacker News

koakuma-chanyesterday at 8:58 PM2 repliesview on HN

I guess when you're brand new you don't know about the mod operator?


Replies

zahlmantoday at 2:42 PM

Even if you don't know about modulo, or (floor) division, you could subtract in a loop and see if you reach zero. Obviously not a good approach, but would demonstrate the kind of basic problem solving skill and ability to "write any working code at all" that this sort of thing is supposed to screen for.

You could improve that and still avoid any division or modulus by simply keeping track of when the "next fizz" and "next buzz" should occur. (And output "fizzbuzz" when those numbers are the same and you reach them.)

IshKebabyesterday at 9:27 PM

Yeah I've interviewed people who didn't.