Multiplication and addition, but in a weird way.

118 Views Asked by At

'calculate the product of x and y by accumulating the sum of x copies of y'

I'm stumped, what is it this exercise actually wants me to do? Express $x$ * $y$ as something else? I'm allowed to use an algorithm (i.e. pseudocode/math) instead of algebra, if anyone can help.

2

There are 2 best solutions below

0
On

I would write an algorithm in pseudocode using a FOR loop to add $y$ to a variable (initialised as zero) $x$ times.

0
On

As you can see in the comment what the question is asking you to do.

Here is the pseudocode...

  1. Initialize a variable 'sum' to zero.

2.Initialize the values if x and y or you can even take them as inputs from the user.

3.start a loop

sum = sum + x

Repeat this y number of times.

  1. Display sum as product of x and y.

You can interchange the third step with this

  1. Start a loop

    sum = sum + y

    Repeat this x number of times.