Click to start working through an example. Click on the steps of the algorithm to see the values of the variables in each step. First click on step 1. and then on the following steps in the order of execution.
Division Algorithm. for positive integers.
Input:a natural number a and a natural number b
Output:Two integers q and r such that a=(q ⋅ b) + r and 0 ≤ r < b
  1. if a < b then return 0,a
  2. let q := 0
  3. let r := a
  4. repeat
    1. let q := q + 1
    2. let r := r - b
  5. until r < b
  6. return q,r