Implement a division algorithm in your favourite language which handles integer division. It need only handle positive numbers - but bonus points if it handles negative and mixed-sign division, too. Results are rounded down for fractional results.
The program may not contain the /, \, div or similar operators. It must be a routine which does not use native division capabilities of the language.
You only need to handle up to 32-bit division.
Input
Take two inputs on stdin separated by new lines or spaces (your choice)
740
2
Output
In this case, the output would be 370.
I'll be looking for innovative solutions which do not use repeated subtraction. The solution which is the shortest and takes the least time.
740,2also permitted for the input? ie comma separated? – gnibbler♦ Feb 4 '11 at 10:440.142857... or0. – Thomas O Feb 4 '11 at 12:24