[Solved] The way of thinking in multiply 2 natural numbers (problem solving”)


(multiply(cy, z/c) + y · (z mod c))

When c is the base of your representation (like decimal), then this is how multiplication can be done “manually”. It’s the “shift and add” method.
In c-base cy is a single shift of y to the left (i.e. adding a zero at the right); and z/c is a single shift of z to the right: the right most digit is lost.
That lost digit is actually z mod c, which is multiplied with y separately.

Here is an example with c = 10, where the apostrophe signifies the value of variables in a recursive call.
We perform the multiplication with y for each separate digit of z (retrieved with z mod c). Each next product found in this way is written shifted one more place to the left. Usually the 0 is not padded at the right of this shifted product, but it is silently assumed:

    354    y
   x 29    z
   ----
   3186    y(z mod c) = 354·9 = 3186
 + 708     y'(z' mod c) = yc(z/c mod c) = 3540·2 = 7080
 ------   
  10266

So the algorithm just relies on the mathematical basis for this “shift and add” method in a given c-base.

solved The way of thinking in multiply 2 natural numbers (problem solving”)