DONAT STEMSciences and MathsENFR
Learn · Mathematics

How many passwords are possible? Permutations and combinations

A short explainer with a free virtual lab to try it yourself.

Short answerUse the multiplication principle: multiply the number of choices for each position. A 4-digit PIN has 10 × 10 × 10 × 10 = 10 000 possibilities. If the digits cannot repeat, there are 10 × 9 × 8 × 7 = 5 040. When order matters you count permutations; when it does not, you count combinations.

🧪 Try it in the free lab. In the free Counting lab you build PINs and passwords, count the possibilities, and see how long a computer would need to guess them.

Open the lab →

The multiplication principle

If one choice can be made in m ways and a second in n ways, both together can be made in m × n ways. For passwords, each character is one choice.

  • 4-digit PIN, digits may repeat: 10⁴ = 10 000.
  • 6 lowercase letters: 26⁶ = 308 915 776.
  • 8 characters from lowercase, uppercase and digits (62 symbols): 62⁸ ≈ 2.18 × 10¹⁴.

Permutations: order matters

The number of ways to arrange r objects chosen from n different objects is

nPr = n! ÷ (n − r)!

Example: a class of 10 elects a head, a deputy and a secretary. Order matters, because the posts are different: ¹⁰P₃ = 10 × 9 × 8 = 720 ways.

Combinations: order does not matter

nCr = n! ÷ (r! (n − r)!)

Example: the class chooses 3 students to clean the laboratory. All three do the same job, so order does not matter: ¹⁰C₃ = 720 ÷ 3! = 720 ÷ 6 = 120 ways. Each group of three was counted 6 times in the permutations.

How long would guessing take?

Suppose a computer tries 1 000 guesses per second.

  • 4-digit PIN: 10 000 ÷ 1 000 = 10 seconds.
  • 8 characters from 62 symbols: 2.18 × 10¹⁴ ÷ 1 000 = 2.18 × 10¹¹ s, about 6 900 years.

Each extra character multiplies the number of possibilities by the size of the alphabet. That is why length matters most. A long passphrase of four random words is both strong and easy to remember. Never use your birth date or name, which are guessed first.

🧪 Counting lab: passwords, permutations and combinations · free, works on any phone, with graphs, questions and a lab report.

Start the lab →

Questions people ask

What does n! mean?

n factorial: n × (n − 1) × … × 2 × 1. For example 4! = 24, and 0! = 1.

Is a lock code a combination?

In mathematics, no: the order of the digits matters, so it is a permutation.

What is the probability of guessing a 4-digit PIN in one try?

1 in 10 000, or 0.0001.

Practise this topic

Written by BIZIYAREMYE Donat, Experienced Physics and STEM Educator, Rwanda. Published 30 November 2026. Found a mistake? Write on WhatsApp 0788 804 242. More explainers · All Interactive Labs