JW,
i know that, we know that!
The modulo way is the fastest option. No Discussion!
The thing is: The Assignment never specified "...in as fast a way as possible...."
What's making me flying off the handle is, never seeing the most obvious way (and that is de facto the String-Operation, because we do it every day in real life), and then ask "Is there a better way?"
The same for answers like Thaddy's:
The OP is obviously a beginner, and from the way it's phrased he doesn't have an ounce of experience with programming (e.g in another Language C, VB, take your pick), because then he would have known, that there is a "string"-way, and a "math"-way, and he'd just ask "I know how to do it in C++, but how do i do it in Pascal?".
For me, Thaddy's advice is like going for your driving license, and the instructor tells you how Lewis Hamilton is determining breaking points and the apex of a corner for him to know when to hit the gaspedal again.
You should learn to walk first, before running.