Bummer! This is just a preview. You need to be signed in with a Basic account to view the entire video.
Start a free Basic trial
to watch this video
Let's take a look at the challenge we'll be working through
-
0:00
All right, the problem we're going to solve is a pretty common one and
-
0:03
is used in interview questions fairly often.
-
0:06
It's called the fizz buzz problem.
-
0:08
And here's how it goes.
-
0:10
Given a random number if the number is divisible by three,
-
0:14
then you print out the string Fizz exactly like I've shown you.
-
0:19
And if it's divisible by five, then you print out the word buzz,
-
0:23
again like you see here.
-
0:25
Remember when writing code and printing strings the case of each letter,
-
0:30
that is whether it's uppercase or lowercase, matters.
-
0:33
Lastly if it's divisible by both three and five then print FizzBuzz.
-
0:39
If the number isn't divisible by either, then just print the number out, itself.
-
0:44
This is a good challenge to attempt,
-
0:47
because it takes into account many of the different things we've learned,
-
0:51
and there's different ways that you can solve it.
-
0:53
If you're having a tough time, don't worry.
-
0:56
I've provided the solutions in a video following this one, but try your best
-
1:00
before you watch that video, you'll feel way better if you figure it out yourself.
-
1:05
As a hint, one way you can figure out if a number is divisible by another
-
1:10
is by using the remainder operator.
-
1:13
We know that 14 is perfectly divisible by 7 because the remainder is zero.
-
1:19
After this video,
-
1:20
there's an empty code challenge where you can paste your solution.
-
1:24
It's probably easier for you to work on it in a playground and
-
1:27
get a working solution, which you can then paste in the editor.
-
1:30
All right, good luck.
You need to sign up for Treehouse in order to download course files.
Sign up