Before we start, did you try solving the workbook yourself?
If not, please click the link in the resources folder and follow the instructions for this workbook.
Welcome to Work Book 5.7.
It tells us to see learn the part for detailed instructions.
Let's do just that task One is to make a4a loop that counts from 0 to 18.
So we will say four.
The counter is going to start an AI equaling zero and the four loop is going to keep running so long
as AI is smaller than 19.
Once we reach 19, we want the loop to break and then we'll say I plus, plus.
And every time the loop runs, we're going to print.
I guess, the number itself.
All right.
It's not worth visualizing the runtime just yet.
Task two is to set up an if ls if L statement, which checks if a number is a multiple of three.
Market forces five.
Market Buzz.
If it's a multiple of three and five market forces Buzz.
Easy enough now for a number to be a multiple of three, let's say like nine, 12 or 15.
All of these numbers divided by three return a remainder of zero.
Here we can say if.
The number that's currently being iterated through.
If that number modulus three, returns a remainder of zero.
Then we mark this number as fiz.
But if the current number being iterated through, if dividing it by five returns a remainder of zero.
Then we mark it as buzz.
Not sure why Autocomplete is not working.
Otherwise.
If that number modulus three equals zero and modulus five equals zero.
So if the number being iterated through is a multiple of three and is a multiple of five, then we market
as fest buzz.
All right.
I think we're good.
I'm going to put a breakpoint right here, and let's see if what we have currently works.
So I is going to start at zero now.
Zero divided by three is going to return a remainder of zero and zero divided by five is also going
to return a remainder of zero.
So while this meets the requirements for phase buzz, what's going to print instead is physx.
Because the first condition gets satisfied and it marks our number zero as far as that is not good.
You will remember, I'll learn the part.
I left you with a hint.
There are three conditions for fizz, buzz and fizz buzz, and you need to be careful about their order.
If something is Physx buzz, it also satisfies the conditions for Physx and buzz.
So the number is zero.
It satisfied the conditions for Physx buzz, but it also satisfies the condition for Physx because this
executed first it marked it as physx.
So what we need to do is make sure that the requirements for Physx buzz take precedence over the others.
So first we check if something meets the requirements for MBAs.
If it doesn't, then we check if it's fizz or buzz.
No Right.
And that was basically the entire trick behind this workbook.
So zero divided by three returns a remainder of zero divided by five returns a remainder of zero.
So it is marked as sbas.
That is perfect.
Let me put some space.
Are we doing that?
All right, now I equals one after we increment it, one divided by three does not return a remainder
of zero, nor does it return a remainder of zero if divided by five.
So it's not fizz buzz.
It's not fizz.
It's not buzz either.
So it gets skipped.
Same thing goes for number two.
Now the number three divided by three does return a remainder of zero, but it does not satisfy this
requirement.
So this whole thing returns false, but it does satisfy this requirement.
So three gets marked as fiz.
That is perfect.
The number four.
Again, nothing.
The number five does meet this requirement, not this one.
So this gets evaluated to false does not run.
This will also be false.
Five divided by five does return a remainder of zero.
So this gets marked as buzz.
And if I just press continue to resume execution, naturally there are no other breakpoints, so the
whole thing completes.
Let's see if what we have matches what's honoring the part 0356 phase Buzz phase, Buzz, fist phase.
And that is exactly what we have in our terminal.
That is perfect.
I hope you enjoyed this breakpoint session.