Skip to main content
Post Reopened by user8397947, acrolith, mbomb007, DJMcMayhem, Pavel
deleted 60 characters in body; edited tags
Source Link
mbomb007
  • 23.5k
  • 7
  • 63
  • 135

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. Using repeated subtraction is not allowed.

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 timewins.

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.

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. Using repeated subtraction is not allowed.

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.

The solution which is the shortest wins.

edited tags
Link
cat
  • 5.9k
  • 2
  • 26
  • 44
Post Closed as "Not suitable for this site" by Dennis
edited tags
Link
Kevin Brown-Silva
  • 6.5k
  • 5
  • 42
  • 59
Tweeted twitter.com/#!/StackCodeGolf/status/33493220633616384
Source Link
Thomas O
  • 3.4k
  • 2
  • 25
  • 35
Loading