Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

division
multiplication
modulo
quotient
remainder

How to divide integers without division/multiplication/modulo

Educative Answers Team
svg viewer

The theory of division

When we divide an integer (D) by another integer (E), we obtain a quotient (Q) and remainder ®. Q represents the number of times that E occurs in D; in simpler terms, Q is the number of parts, of size E, that D can be broken into. Once all of ​these parts are taken out of D, the remaining part is the remainder.

We have a bar of length 11
1 of 3

Algorithm and code

By this point, you should have realized that the quotient can be found by repeatedly subtracting E from D, and recording the number of times ​that this subtraction is performed.

def Divide(D,E):
  R = D
  Q = 0


  while R >= E:
    R = R - E
    Q += 1

  return Q

D = 11
E = 4
print("Quotient from our function: ",Divide(D,E))
print("Actual Quotient: ", D // E)

RELATED TAGS

division
multiplication
modulo
quotient
remainder
Copyright ©2022 Educative, Inc. All rights reserved
RELATED COURSES

View all Courses

Keep Exploring