I remember this type of questions in P4, but they were rare, and usually we either skipped it or just brute force the answer. But, i cannot remember it coming out in test or exam.... I remember this usually comes out in those kind of primary sch math olympiads etc. Maybe its for those GEP people? Cause i was in GEP, and i distinctly remember seeing this kind of questions.