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?

  • blobby green style avatar for user kmsmath6
    What is the best way to figure out if a number (especially a large number) is prime?
    (436 votes)
    Default Khan Academy avatar avatar for user
    • blobby green style avatar for user merijn.koster.avans
      What I try to do is take it step by step by eliminating those that are not primes.

      step 1. except number 2, all other even numbers are not primes.
      step 2. except number 5, all other numbers divisible by 5 are not primes

      so far so good :), now comes the harder part especially with larger numbers

      step 3: I start with the next lowest prime next to number 2, which is number 3 and use long division to see if I can divide the number.

      step 4: I repeat step 3 with trying to divide by the prime 5, 7 , 11 and onward until the prime is found or not ^^

      hope it helps.
      (259 votes)
  • blobby green style avatar for user emilysmith148
    Is a "negative" number not natural??
    (27 votes)
    Default Khan Academy avatar avatar for user
  • mr pants teal style avatar for user Jennifer Lemke
    What is the harm in considering 1 a prime number? It is true that it is divisible by itself and that it is divisible by 1, why is the "exactly 2" rule so important?
    (2 votes)
    Default Khan Academy avatar avatar for user
  • starky ultimate style avatar for user SLow
    Why is one not a prime number i don't understand?
    (2 votes)
    Default Khan Academy avatar avatar for user
    • hopper cool style avatar for user SciπPar
      I have question for you
      Would consider 1 and 1 different numbers?
      I wouldn’t. The mathematical community doesn’t either.
      So when a number is divisible by itself and one, it’s prime asking the number itself isn’t one
      I hope this helps you
      (2 votes)
  • starky sapling style avatar for user kollan savoie92
    when you have a prime number does it depend on were the number is in the place value? like I mean if you were to have a bunch of numbers and only one had a prime number in it how would you know which one has the prime number?
    (5 votes)
    Default Khan Academy avatar avatar for user
    • duskpin ultimate style avatar for user Saalih Rahim
      It does not necessarily depend on where the number is in the place value to determine if it's prime. However, you should look at the digit in the ones place before trying to determine if the number is prime or composite. By doing this, you can eliminate the numbers that cannot be prime, for example, if you have a set of numbers, with some of them having even numbers in the ones place, then you can automatically eliminate those because all even numbers are composite with the exception of 2. So in my opinion, I think that the best way to determine if a number is prime is to see if it is divisible by other smaller numbers, and when no clear factors can be determined, then you can consider the number to be prime. I hope this helps in answering your question.
      (2 votes)
  • marcimus pink style avatar for user gabriella.maldonado
    What specifically is 1 if it's not a prime or composite number?
    (5 votes)
    Default Khan Academy avatar avatar for user
  • leaf green style avatar for user SoccerboyH2
    Is 0 a prime or composite number? Why?
    (3 votes)
    Default Khan Academy avatar avatar for user
  • leaf blue style avatar for user Victor
    Why does a prime number have to be divisible by two natural numbers? Why can't it also be divisible by decimals?
    (2 votes)
    Default Khan Academy avatar avatar for user
    • female robot grace style avatar for user Sonata
      All numbers are divisible by decimals. For example, you can divide 7 by 2 and get 3.5 . When using prime numbers and composite numbers, stick to whole numbers, because if you are factoring out a number like 9, you wouldn't say its prime factorization is 2 x 4.5, you'd say it was 3 x 3, because there is an endless number of decimals you could use to get a whole number.
      (2 votes)
  • mr pink red style avatar for user PetriniJM
    Is zero prime or composite?
    (2 votes)
    Default Khan Academy avatar avatar for user
  • male robot hal style avatar for user Lawrence Lewis
    I don't get what's going on
    (4 votes)
    Default Khan Academy avatar avatar for user

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.