All gamesiPhone calculatorBlog

Home › iPhone calculator › Factorial

iPhone Calculator Factorial: How to Use the x! Key

A Phoney’s Calculator Class tutorial

Factorial15 minutes

Five friends want to stand in a line for a photograph. Who stands on the left? Who goes in the middle? If you move two people and swap them, is that a new photo? Count carefully and you will find there are 120 different ways to line up just five people. For ten people, the number jumps to more than three and a half million. For a full deck of 52 cards, the number of possible shuffles is so large that every well-shuffled deck in history has almost certainly been in an order that never appeared before.

The mathematical tool behind those numbers is the factorial, and your iPhone Calculator can work it out with a single key: x!. The exclamation mark is not there for excitement. It is the official symbol for factorial.

In this tutorial you will learn what a factorial is, how to use the x! key, and how to apply it to everyday questions about arrangements, passwords, lottery tickets and card hands. You will also learn a clever cancelling trick that keeps big calculations clean and accurate. Turn your iPhone sideways, open Calculator, and let us count.

What a factorial is

The factorial of a whole number is the product of every whole number from that number down to 1. We write it with an exclamation mark after the number.

Notice how quickly the numbers grow. Each time you move up by one, you multiply the previous answer by the new number. So 6! is 5! times 6, which is 120 × 6 = 720. And 7! is 720 × 7 = 5,040.

This “building up” pattern gives you a useful way to think about factorials: n! = n × (n − 1)! Each factorial is the next smaller one multiplied by the number itself.

Here is a short list worth remembering:

You do not need to learn these by heart. Your calculator knows them. But seeing the growth helps you sense whether an answer is sensible.

The strange case of 0!

There is one special value that surprises almost everyone: 0! equals 1. Not zero. One.

It may feel wrong, because there are no numbers to multiply. Here is the idea that makes it sensible. A factorial counts the number of ways to arrange things. How many ways can you arrange zero objects? There is exactly one way: do nothing. So 0! is 1.

There is also a pattern argument. We know that 3! = 4! ÷ 4, that 2! = 3! ÷ 3, and that 1! = 2! ÷ 2. Following the pattern one more step, 0! = 1! ÷ 1 = 1. The pattern would break if 0! were anything else.

You can check it on your calculator: type 0 and tap x!. The screen shows 1.

Where to find the x! key

To reach the key, switch off your portrait orientation lock in Control Center, open the Calculator app, and turn the iPhone sideways. In the scientific keypad, look at the fourth row on the left. You will see x! at the start of that row, next to sin, cos and tan.

The method is the same as for the squared and root keys. You type the number first, then tap x!. The key acts immediately, so no equals is needed.

  1. Type 5.
  2. Tap x!.
  3. The screen shows 120.

Try a few more:

Factorials grow so fast that the calculator soon switches to scientific notation, which you will master in Part 8. For now, just know that e12 means “times ten to the power of twelve.”

What factorials count: arranging things

The most direct use of a factorial is counting the number of ways to arrange a group of different things in order. Here is why.

Suppose you have three books, A, B and C, and you want to put them on a shelf. You have three choices for the first position. Once that is chosen, you have two choices for the second position. Then only one choice remains for the last. The total is 3 × 2 × 1 = 6, which is 3!. The six arrangements are ABC, ACB, BAC, BCA, CAB and CBA.

The same logic works for any number of items. For five books, the count is 5! = 120. For ten books, 10! = 3,628,800.

Here are real-life examples to try on your calculator:

Phoney’s tip: if you can describe a situation as “in how many different orders can I place these?”, a factorial is probably the answer.

When you only pick some of the items

Often you do not arrange everything. Imagine eight runners in a race. How many different ways can the gold, silver and bronze medals be awarded?

There are 8 choices for gold, 7 remaining for silver, and 6 remaining for bronze. The total is 8 × 7 × 6 = 336.

You can write this using factorials as 8! ÷ 5!. Why? Because 8! is 8 × 7 × 6 × 5 × 4 × 3 × 2 × 1, and dividing by 5! removes the tail 5 × 4 × 3 × 2 × 1, leaving just 8 × 7 × 6. Cancelling the tail is the key idea of this whole section.

On your calculator:

  1. Type 8 and tap x!. The screen shows 40,320.
  2. Tap ÷.
  3. Type 5 and tap x!.
  4. Tap =. The screen shows 336.

The general rule for choosing r items in order from n items is n! ÷ (n − r)!. This type of counting is called a permutation.

Another example is a PIN code. How many four-digit PIN codes can you make if no digit may repeat? You have 10 choices for the first digit, 9 for the second, 8 for the third and 7 for the fourth: 10 × 9 × 8 × 7 = 5,040. With factorials, that is 10! ÷ 6!.

When order does not matter

Now switch the question. Imagine you are ordering a pizza with three toppings chosen from a menu of eight, and the order of the toppings does not matter. Cheese-ham-olives is the same pizza as olives-cheese-ham.

If order mattered, there would be 8 × 7 × 6 = 336 choices. But every group of three toppings can be listed in 3! = 6 different orders, and they all make the same pizza. So we divide by 6: 336 ÷ 6 = 56 different pizzas.

The general rule for choosing r items from n when order does not matter is n! ÷ (r! × (n − r)!). This is called a combination.

To compute it on the iPhone, you can use brackets on the scientific keypad:

8 x! ÷ ( 3 x! × 5 x! ) =

The screen shows 56. If you prefer to avoid brackets, use the memory keys from Part 1:

  1. Tap mc.
  2. Type 3, tap x!, tap ×, type 5, tap x!, tap =. The screen shows 720.
  3. Tap m+.
  4. Type 8, tap x!, tap ÷, tap mr, tap =. The screen shows 56.

Here are more combination examples:

The cancelling trick for big numbers

Try typing 52 x! and you will see an enormous number: about 8.0658e67. That is a 68-digit number. Dividing two such giant numbers works in principle, but it is wasteful, and the calculator can lose a tiny bit of accuracy because it only keeps a certain number of digits.

A smarter approach is to cancel before you calculate. Let us find the number of five-card poker hands from 52 cards. The formula is 52! ÷ (5! × 47!). Because 52! equals 52 × 51 × 50 × 49 × 48 × 47!, the 47! cancels, and you are left with:

(52 × 51 × 50 × 49 × 48) ÷ (5 × 4 × 3 × 2 × 1)

On the calculator:

  1. Type 52 × 51 × 50 × 49 × 48 =. The screen shows 311,875,200.
  2. Tap ÷, type 5, tap x!, tap =.
  3. The screen shows 2,598,960.

Another famous example is the lottery. In a lottery where you choose 6 numbers from 49, the number of possible tickets is 49 × 48 × 47 × 46 × 45 × 44 ÷ 6!. The multiplication gives 10,068,347,520. Divide by 720, and you get 13,983,816. Your chance of winning with a single ticket is about one in fourteen million.

Repeated letters and the division trick

What if some of the things you are arranging are identical? The word BANANA has six letters, but it has three A’s and two N’s. If all the letters were different, there would be 6! = 720 arrangements. But swapping two A’s does not make a new word. So we divide by the number of ways to shuffle the A’s (3!) and the N’s (2!):

6! ÷ (3! × 2!) = 720 ÷ 12 = 60.

On the calculator: type 6, tap x!, tap ÷, type 3, tap x!, tap ÷, type 2, tap x!, tap =. Dividing step by step works because dividing by 6 and then by 2 is the same as dividing by 12. The screen shows 60.

Try the word LEVEL, which has two L’s and two E’s: 5! ÷ (2! × 2!) = 120 ÷ 4 = 30.

Factorials and the number e

Here is a lovely surprise. If you add up the reciprocals of the factorials, 1 + 1 + 1/2 + 1/6 + 1/24 + 1/120 and so on, the total creeps toward the famous number e, which is about 2.71828. You can try this with the x! key, the 1/x key and the memory.

  1. Tap mc.
  2. Type 1 and tap m+. (This is 0!, which gives 1.)
  3. Type 1 and tap m+. (This is 1/1!.)
  4. Type 2, tap x!, tap 1/x, and tap m+. (That adds 1/2.)
  5. Type 3, tap x!, tap 1/x, and tap m+. (That adds 1/6.)
  6. Type 4, tap x!, tap 1/x, and tap m+.
  7. Type 5, tap x!, tap 1/x, and tap m+.
  8. Tap mr.

The screen shows about 2.716667. After only six terms, the total is already very close to e, which is 2.718282. Keep adding the next terms and it gets closer and closer. This connection is why factorials show up in calculus and in many scientific formulas.

How big can a factorial get?

Factorials grow faster than almost any pattern you will meet. Here are some milestones:

If you keep going, the calculator eventually shows Error because the answer is too large to fit. You do not need to find that limit exactly. It is enough to know that factorials are the kind of number that outgrows any machine very quickly.

There is also a famous estimate called Stirling’s approximation, which says that n! is close to the square root of (2πn) multiplied by (n ÷ e) to the power n. For 10, the approximation gives about 3,598,696, compared with the true value 3,628,800. It is within one percent, which is impressive for such a quick formula.

Common mistakes and how to avoid them

Mistake 1: using a negative number or a decimal. Factorials are defined for whole numbers that are zero or larger. The calculator will show an error for a negative number. Stick to whole numbers while learning.

Mistake 2: forgetting that 0! is 1. Some combination problems need 0!, such as choosing all items from a group. Your calculator handles it correctly.

Mistake 3: typing the number after the key. On the iPhone, type the number first and tap x! second.

Mistake 4: mixing up permutations and combinations. Ask yourself, “does the order matter?” If a gold-silver-bronze order matters, divide only by (n − r)!. If a team of three has no order, also divide by r!.

Mistake 5: using the factorial of a sum. (3 + 4)! is 7!, not 3! + 4!. Press equals first, then tap x!.

Mistake 6: calculating enormous factorials when you could cancel. For big problems, cancel the common tail first, as in the poker and lottery examples.

Practice questions

Try these before you look at the answers.

Question 1. Work out 7!.

Question 2. Eight runners compete in a race. In how many ways can gold, silver and bronze be awarded?

Question 3. A pizza shop offers 8 toppings. How many different three-topping pizzas can you order?

Question 4. How many different arrangements are there of the letters in BANANA?

Question 5. How many four-digit PIN codes are there if no digit can be repeated?

Question 6. How many times bigger is 10! than 9!?

Question 7. How many five-card hands can be dealt from a 52-card deck? Use the cancelling method.

Question 8. What is 0!?

Answers

Quick reference

Frequently asked questions

Why does the factorial grow so fast? Because each step multiplies by a bigger number than the one before. Adding one more item multiplies the number of arrangements by the new total.

Can I take the factorial of a decimal? Mathematicians have a way to extend factorials to decimals, but for everyday use, stay with whole numbers.

Why does my screen show something like 1.307674368e12? That is scientific notation. The e12 means “times ten to the twelfth power.” You will study it in Part 8.

Is there a faster way to count combinations? Yes. Use the cancelling method, because it avoids huge numbers and keeps your answer exact.

What comes next

You can now count the number of ways things can happen. In Part 5, you will turn to a very different but equally useful set of keys: sin, cos and tan. Trigonometry lets you find heights and distances you cannot measure directly, such as the height of a tree or the width of a river. Before you start, remember one idea from this tutorial. Large problems often become easy when you break them into small, cancelling steps.

← All iPhone calculator lessons