9/12/17

Algorithm PU

This algorithm works like  algorithm PD, it is only one difference with destinations, this means sign in operation. The base P is bigger than divisor D.

Now the unpaired step use other operator:
do from most signicicant digit
  add to next digit (+ this*R)
until we take the least significant one; 

Example in decimal system:
358 / 7
we multiply by 7-10=-3 each numbers (in this algorithm we substract negative, so add), they we get from digit of number. We can upgrade this and take the number nearer zero. The last number /digit is the remainder from division. 
  3
3*3+5 = 14 = 0 (mod 7)
3*0+8 = 8 = 1 (mod 7)

This method allows get quotient, until we be very caution, verify all changes of digits and repair becoming list of numbers.
In this example we got list [3, 0, 1] in decimal, but we used some congruences inside. The list for quotient looks as follow
[3, 2*7+0, 1*7+1] = [3+2, 0+1, 1] = [5,1,1]
and returns a quotient 51 and remainder 1.