00:03
So in this video, we're told that one way to do multiplication is through repeated addition.
00:09
And so they give us an algorithm to work through here.
00:13
And so we're given two positive numbers a and b.
00:16
So we're given two positive numbers a and b.
00:20
And we want to come up with an algorithm here.
00:22
So we wanted a number c, which is that contains the product of a times b.
00:30
Okay, that's what we're shooting for, some number c here.
00:33
And so in the algorithm, it says step one, right, set the value of c equal to zero.
00:40
Okay, so c is equal to zero.
00:45
Okay, so c is actually going to contain our product, and we want to start it at zero.
00:50
Because if we're going to do repeated addition, we want to start at zero.
00:54
So step two, set the value of i.
00:59
Let's set the value of i equal to a.
01:03
So set the value of i equal to a.
01:06
So a is how many times we're going to do the repeated addition.
01:11
I could also set i equal to b that would work the same way.
01:16
So three, repeat steps blank and blank until the value of i equals blank.
01:24
So we want to repeat steps blank and blank until i equals something.
01:42
Okay.
01:43
Step 4, we're going to set the value of c to be equal to something.
01:50
In step 5, we're going to set the value of, we're going to subtract 1 from i.
01:56
So i'm going to say i equals i minus 1.
02:01
Okay, that's how we subtract 1 from i.
02:04
Step 6 is to print out the final answer to c and step 7 stop.
02:09
So i'm not going to write those two things.
02:11
Let's try to figure out what's going on here.
02:13
Right so if i let c equals zero to start with and the idea here is that i want to repeat adding a certain amount um i want to add a number a certain amount of times so if i'm doing a times b right i want to add b a times all right so i'm going to add b to c so down here in step five i'm going to step four i'm to say let's see equal c plus b and then remember because i already set a to i and so then i'm going to say i equals i minus one so i is going to come become one less right so what i basically want to do is i want to repeat these two steps right here so i want to repeat step four and step five and i'm going to add in i'm going to do this until i get all the way down to i equals zero, okay, because i'll be subtracting one each time, so i equals zero.
03:26
All right, so let's work, let's do this with two numbers here so that we can see how the flow goes.
03:33
Okay.
03:34
So here, let's start with a equals three and b equals five, right? so three times five, we know is 15.
03:46
So let's go through our algorithm here.
03:48
Okay, step one here, right? step one, we have c equals zero.
03:56
Step two, we have i equals my a value is three...