In real life, you gain some experience and can generally predict in what direction the software might go in the future.
Given FizzBuzz, I'd guess that business asked me to handle divisibility by 3 and divisibility by 5, so it's just a matter of time until they want divisibility by 7. However, it's not very probable they will want to add a case for when a number is a square.
That would lead my to a solution based on the general principle of prime factors, and not the special rules, so basically string concatenation.
If business wants squares, I'll say "well, that's very different from the things we had until now, so this will take some time".
Sure but as the requirement keeps changing, I will start identifying patterns and how best to prepare for future changes without changing the code too much.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
In real life, you gain some experience and can generally predict in what direction the software might go in the future.
Given FizzBuzz, I'd guess that business asked me to handle divisibility by 3 and divisibility by 5, so it's just a matter of time until they want divisibility by 7. However, it's not very probable they will want to add a case for when a number is a square.
That would lead my to a solution based on the general principle of prime factors, and not the special rules, so basically string concatenation.
If business wants squares, I'll say "well, that's very different from the things we had until now, so this will take some time".
Sure but as the requirement keeps changing, I will start identifying patterns and how best to prepare for future changes without changing the code too much.