You'd be amazed at the percentage of people who fail this test. I can't say I have interviewed many people, but even seeing one or two people fail this test for a technical role is mind-boggling.
I could imagine someone not from a CS background to fail it by perhaps not recognizing they need to the modulus operator or even being aware of its existence?
Outside that, yeah. It indeed boggles the mind that the vanilla version of it could be failed by anyone who has taken elementary programming course.
In order to test your real problem-solving skills, you should allow the use of Internet search, because not all computer professionals can remember a particular algorithm.
Outside that, yeah. It indeed boggles the mind that the vanilla version of it could be failed by anyone who has taken elementary programming course.