Your question is Divide Two Numbers Without Division. Start with the requirements on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
Hewlett Packard Enterprise Development systems may need arithmetic logic implemented without relying on hardware division or multiplication instructions. Given two integers, compute the quotient without using /, //, or *.
Implement divide(a, b) with these rules:
a divided by b, truncated toward zero.b is never zero.[-2147483648, 2147483647].The solution should improve on subtracting the divisor one time per quotient unit by repeatedly doubling the largest usable divisor chunk.
Input: two integers a and b.
Output: one integer representing a / b, truncated toward zero and clamped to the signed 32-bit range.
def divide(a, b):