3 ms·
I would expect either a pair of integers, either a rational number or a quotient and remainder. 523/6 is not 87. As for "solved problems," it is not at all un
by betterunix 13y ago
I would expect either a pair of integers, either a rational number or a quotient and remainder. 523/6 is not 87.
As for "solved problems," it is not at all unusual to be asked to re-implement an algorithm that is already implemented elsewhere. Maybe there is no implementation for your platform. Maybe you are writing a new language. You could find yourself implementing integer division just as much as you could find yourself implementing a sorting algorithm, a hash table, etc.
[Edit: Also worth noting is that in the context of education it is common to ask students to re-implement known algorithms and build up systems on their own.]
- redblacktree 13y agoIn the context of education, I agree, but you strech credulity with this: > Maybe there is no implementation for your platform. I challenge you to find me a single example of a platform that does not already have an implementation for integer division. This functionality is basic. Edit: Also, you seem to have strange expectations with respect to results of integer division. Many languages in common use will give the result above. If you want the remainder, you're expected to use modulus. For example: >>> '%s %s/%s' % (523 / 6, 523 % 6, 523) '87 1/523' >>>