If you're seeing this message, it means we're having trouble loading external resources on our website.

If you're behind a web filter, please make sure that the domains *.kastatic.org and *.kasandbox.org are unblocked.

Main content

Prime numbers

Prime numbers are numbers that have only 2 factors: 1 and themselves. For example, the first 5 prime numbers are 2, 3, 5, 7, and 11. By contrast, numbers with more than 2 factors are call composite numbers. Created by Sal Khan.

Want to join the conversation?

Video transcript

In this video, I want to talk a little bit about what it means to be a prime number. And what you'll see in this video, or you'll hopefully see in this video, is it's a pretty straightforward concept. But as you progress through your mathematical careers, you'll see that there's actually fairly sophisticated concepts that can be built on top of the idea of a prime number. And that includes the idea of cryptography. And maybe some of the encryption that your computer uses right now could be based on prime numbers. If you don't know what encryption means, you don't have to worry about it right now. You just need to know the prime numbers are pretty important. So I'll give you a definition. And the definition might be a little confusing, but when we see it with examples, it should hopefully be pretty straightforward. So a number is prime if it is a natural number-- and a natural number, once again, just as an example, these are like the numbers 1, 2, 3, so essentially the counting numbers starting at 1, or you could say the positive integers. It is a natural number divisible by exactly two numbers, or two other natural numbers. Actually I shouldn't say two other, I should say two natural numbers. So it's not two other natural numbers-- divisible by exactly two natural numbers. One of those numbers is itself, and the other one is one. Those are the two numbers that it is divisible by. And that's why I didn't want to say exactly two other natural numbers, because one of the numbers is itself. And if this doesn't make sense for you, let's just do some examples here, and let's figure out if some numbers are prime or not. So let's start with the smallest natural number-- the number 1. So you might say, look, 1 is divisible by 1 and it is divisible by itself. You might say, hey, 1 is a prime number. But remember, part of our definition-- it needs to be divisible by exactly two natural numbers. 1 is divisible by only one natural number-- only by 1. So 1, although it might be a little counter intuitive is not prime. Let's move on to 2. So 2 is divisible by 1 and by 2 and not by any other natural numbers. So it seems to meet our constraint. It's divisible by exactly two natural numbers-- itself, that's 2 right there, and 1. So 2 is prime. And I'll circle the prime numbers. I'll circle them. Well actually, let me do it in a different color, since I already used that color for the-- I'll just circle them. I'll circle the numbers that are prime. And 2 is interesting because it is the only even number that is prime. If you think about it, any other even number is also going to be divisible by 2, above and beyond 1 and itself. So it won't be prime. We'll think about that more in future videos. Let's try out 3. Well, 3 is definitely divisible by 1 and 3. And it's really not divisible by anything in between. It's not divisible by 2, so 3 is also a prime number. Let's try 4. I'll switch to another color here. Let's try 4. Well, 4 is definitely divisible by 1 and 4. But it's also divisible by 2. 2 times 2 is 4. It's also divisible by 2. So it's divisible by three natural numbers-- 1, 2, and 4. So it does not meet our constraints for being prime. Let's try out 5. So 5 is definitely divisible by 1. It's not divisible by 2. It's not divisible by 3. It's not exactly divisible by 4. You could divide them into it, but you would get a remainder. But it is exactly divisible by 5, obviously. So once again, it's divisible by exactly two natural numbers-- 1 and 5. So, once again, 5 is prime. Let's keep going, just so that we see if there's any kind of a pattern here. And then maybe I'll try a really hard one that tends to trip people up. So let's try the number. 6. It is divisible by 1. It is divisible by 2. It is divisible by 3. Not 4 or 5, but it is divisible by 6. So it has four natural number factors. I guess you could say it that way. And so it does not have exactly two numbers that it is divisible by. It has four, so it is not prime. Let's move on to 7. 7 is divisible by 1, not 2, not 3, not 4, not 5, not 6. But it's also divisible by 7. So 7 is prime. I think you get the general idea here. How many natural numbers-- numbers like 1, 2, 3, 4, 5, the numbers that you learned when you were two years old, not including 0, not including negative numbers, not including fractions and irrational numbers and decimals and all the rest, just regular counting positive numbers. If you have only two of them, if you're only divisible by yourself and one, then you are prime. And the way I think about it-- if we don't think about the special case of 1, prime numbers are kind of these building blocks of numbers. You can't break them down anymore they're almost like the atoms-- if you think about what an atom is, or what people thought atoms were when they first-- they thought it was kind of the thing that you couldn't divide anymore. We now know that you could divide atoms and, actually, if you do, you might create a nuclear explosion. But it's the same idea behind prime numbers. In theory-- and in prime numbers, it's not theory, we know you can't break them down into products of smaller natural numbers. Things like 6-- you could say, hey, 6 is 2 times 3. You can break it down. And notice we can break it down as a product of prime numbers. We've kind of broken it down into its parts. 7, you can't break it down anymore. All you can say is that 7 is equal to 1 times 7, and in that case, you really haven't broken it down much. You just have the 7 there again. 6 you can actually break it down. 4 you can actually break it down as 2 times 2. Now with that out of the way, let's think about some larger numbers, and think about whether those larger numbers are prime. So let's try 16. So clearly, any number is divisible by 1 and itself. Any number, any natural number you put up here is going to be divisible by 1 and 16. So you're always going to start with 2. So if you can find anything else that goes into this, then you know you're not prime. And 16, you could have 2 times 8, you could have 4 times 4. So it's got a ton of factors here above and beyond just the 1 and 16. So 16 is not prime. What about 17? 1 and 17 will definitely go into 17. 2 doesn't go into 17. 3 doesn't go. 4, 5, 6, 7, 8, 9 10, 11-- none of those numbers, nothing between 1 and 17 goes into 17. So 17 is prime. And now I'll give you a hard one. This one can trick a lot of people. What about 51? Is 51 prime? And if you're interested, maybe you could pause the video here and try to figure out for yourself if 51 is a prime number. If you can find anything other than 1 or 51 that is divisible into 51. It seems like, wow, this is kind of a strange number. You might be tempted to think it's prime. But I'm now going to give you the answer-- it is not prime, because it is also divisible by 3 and 17. 3 times 17 is 51. So hopefully that gives you a good idea of what prime numbers are all about. And hopefully we can give you some practice on that in future videos or maybe some of our exercises.