How to use the FACT function
What is the FACT function?
The FACT function returns the factorial of a number.
Table of Contents
1. Introduction
What is the factorial of a number?
The factorial of a number n is the product of all positive integers less than or equal to n, and is represented by n!
The factorial of a number n is defined as:
n! = n * (n-1) * (n-2) * ... * 3 * 2 * 1
In other words, the factorial of a number n is the product of all positive integers less than or equal to n.
Some examples:
1! = 1
2! = 2 * 1 = 2
3! = 3 * 2 * 1 = 6
4! = 4 * 3 * 2 * 1 = 24
5! = 5 * 4 * 3 * 2 * 1 = 120
0! = 1
The factorial function grows very quickly as n increases. Factorials are useful in combinatorics for counting permutations and combinations.
How to calculate combinations using factorials?
The formula for combinations is:
C(n, r) = n! / (r! * (n-r)!)
Where:
n = Total number of objects
r = Size of the subset we choose
For example, say we have 5 fruits: apple, banana, orange, mango and peach. We want to calculate how many combinations of 3 fruits there are from this set of 5 fruits.
n = 5 (total fruits) r = 3 (size of subset)
C(5, 3) = 5! / (3! * (5-3)!) = 120 / (6 * 2) = 10
How to calculate permutations using factorials?
For example, ordering 3 letters out of the alphabet.
The formula for permutations is:
P(n, r) = n! / (n - r)!
Where:
n = Total number of objects
r = Number of objects being arranged
For example, say we want to find how many ways we can arrange 3 letters from the alphabet.
n = 26 (total letters) r = 3 (letters we are arranging)
P(26, 3) = 26! / (26 - 3)! = 26! / 23! = 15600
What are permutations?
A permutation is a way of arranging a set of elements in a specific order. For example, if you have three letters A, B, and C, you can arrange them in six different ways: ABC, ACB, BAC, BCA, CAB, and CBA.
Each of these arrangements is called a permutation of the three letters. The order of the objects matters in a permutation, so ABC and BAC are considered different permutations.
The PERMUT and PERMUTATIONA functions are in the Statistical category
What are combinations?
A combination is a way of selecting items from a collection where the order of selection does not matter.
For example, if you have three fruits, say an apple, an orange, and a pear. There are three combinations of two that can be drawn from this set:
- apple and a pear
- apple and an orange
- pear and an orange
The COMBIN and COMBINA functions are in the Math and trigonometry category.
2. Syntax
FACT(number)
number | Required. The number equal to or larger than 0 (zero) for which you want to calculate the factorial. |
If number is not an integer, it is truncated.
Returns an error if the number argument is a text value.
3. Example 1
This example shows how to use the FACT function, the arguments are in cell range B3:B7 and the results are in C3:C7. Cell range D3:D7 shows the calculations in detail.
Formula in cell C3:
- The factorial of number 0 (zero) is 1. The factorial n! is defined as the product of all positive integers less than or equal to n. By this definition, 0! should be the product of no numbers which is typically considered to be 1 (the empty product)
- The factorial of number 1 is also 1. 1! = 1
- The factorial of number 2 is 2. 2! = 2*1
- The factorial of number 3 is 6. 3! = 3*2*1
The FACT function is useful if you want to calculate the number of permutations of a given set of elements.
The following set has three elements: [A, B, C].
3! = 3*2*1 = 6. You can rearrange [A, B, C] in six different permutations.
1, [A, B, C]
2, [A, C, B]
3, [B, A, C]
4, [B, C, A]
5, [C, A, B]
6, [C, B, A]
4. Example 2
How many permutations are there in this data set: [A, B, C, and D] if three items can be selected? Repetition is not allowed.
The number of permutations of a set of n distinct items, taken r at a time, is given by the formula:
nPr = n! / (n - r)!
n! - (read as "n factorial") represents the product of all positive integers less than or equal to n
(n - r)! - represents the product of all positive integers less than or equal to (n - r)
Formula in cell C6:
The formula returns 24, lets calculate this value manually:
For example, if we want to find the number of permutations of 4 items taken 3 at a time, we would calculate:
4P3 = 4! / (4 - 3)!
=(4 * 3 * 2 * 1) / 1
=24 / 1
=24
So, there are 24 possible permutations of 4 items taken 3 at a time.
5. Example 3
How many combinations are there in this data set: [A, B, C, and D] if three items can be selected? Repetition is not allowed.
The math formula to calculate the number of combinations is:
C(n,r) = n!/(r!(n-r)!)
- C = Combinations
- n = objects (number)
- r = sample (number_chosen)
The arguments are in cells C2: and C3:
- C2: 4 (objects)
- C3: 3 (sample)
Formula in cell C6:
Here is how the formula is calculated in greater detail:
C(n,r) = n!/(r!(n-r)!)
=4!/(3!*(4-3)!)
=24/(6*1)
=4
The result is 4 combinations based on 4 objects in total and 3 numbers chosen. This value matches the calculated value in cell C6.
6. Example 4
How many combinations are there in this data set: [A, B, C, and D] if three items can be selected? Repetition is allowed.
The math formula to calculate the number of combinations (repetition allowed) is:
nCr (with repetition) = (n+r-1)! / (r! * (n-1)!)
- n is the total number of items
- r is the number of items being chosen
The arguments are in cells C2: and C3:
- C2: 4 (objects)
- C3: 3 (sample)
Formula in cell C6:
Here is how the formula is calculated in greater detail:
nCr (with repetition) = (n+r-1)! / (r! * (n-1)!)
=(4+3-1)!/(3!*(4-1)!)
=6*5*4*3*2*1/(3*2*1*(3*2*1))
=720/(6*6)
=720/36
=20
The calculated value is 20 which matches the calculated value in cell C6.
6. Function not working
The FACT function returns a
- #VALUE! error if the argument is a non numerical value.
- #NUM! error if the number is negative.
6.1 Troubleshooting the error value
When you encounter an error value in a cell a warning symbol appears, displayed in the image above. Press with mouse on it to see a pop-up menu that lets you get more information about the error.
- The first line describes the error if you press with left mouse button on it.
- The second line opens a pane that explains the error in greater detail.
- The third line takes you to the "Evaluate Formula" tool, a dialog box appears allowing you to examine the formula in greater detail.
- This line lets you ignore the error value meaning the warning icon disappears, however, the error is still in the cell.
- The fifth line lets you edit the formula in the Formula bar.
- The sixth line opens the Excel settings so you can adjust the Error Checking Options.
Here are a few of the most common Excel errors you may encounter.
#NULL error - This error occurs most often if you by mistake use a space character in a formula where it shouldn't be. Excel interprets a space character as an intersection operator. If the ranges don't intersect an #NULL error is returned. The #NULL! error occurs when a formula attempts to calculate the intersection of two ranges that do not actually intersect. This can happen when the wrong range operator is used in the formula, or when the intersection operator (represented by a space character) is used between two ranges that do not overlap. To fix this error double check that the ranges referenced in the formula that use the intersection operator actually have cells in common.
#SPILL error - The #SPILL! error occurs only in version Excel 365 and is caused by a dynamic array being to large, meaning there are cells below and/or to the right that are not empty. This prevents the dynamic array formula expanding into new empty cells.
#DIV/0 error - This error happens if you try to divide a number by 0 (zero) or a value that equates to zero which is not possible mathematically.
#VALUE error - The #VALUE error occurs when a formula has a value that is of the wrong data type. Such as text where a number is expected or when dates are evaluated as text.
#REF error - The #REF error happens when a cell reference is invalid. This can happen if a cell is deleted that is referenced by a formula.
#NAME error - The #NAME error happens if you misspelled a function or a named range.
#NUM error - The #NUM error shows up when you try to use invalid numeric values in formulas, like square root of a negative number.
#N/A error - The #N/A error happens when a value is not available for a formula or found in a given cell range, for example in the VLOOKUP or MATCH functions.
#GETTING_DATA error - The #GETTING_DATA error shows while external sources are loading, this can indicate a delay in fetching the data or that the external source is unavailable right now.
6.2 The formula returns an unexpected value
To understand why a formula returns an unexpected value we need to examine the calculations steps in detail. Luckily, Excel has a tool that is really handy in these situations. Here is how to troubleshoot a formula:
- Select the cell containing the formula you want to examine in detail.
- Go to tab “Formulas” on the ribbon.
- Press with left mouse button on "Evaluate Formula" button. A dialog box appears.
The formula appears in a white field inside the dialog box. Underlined expressions are calculations being processed in the next step. The italicized expression is the most recent result. The buttons at the bottom of the dialog box allows you to evaluate the formula in smaller calculations which you control. - Press with left mouse button on the "Evaluate" button located at the bottom of the dialog box to process the underlined expression.
- Repeat pressing the "Evaluate" button until you have seen all calculations step by step. This allows you to examine the formula in greater detail and hopefully find the culprit.
- Press "Close" button to dismiss the dialog box.
There is also another way to debug formulas using the function key F9. F9 is especially useful if you have a feeling that a specific part of the formula is the issue, this makes it faster than the "Evaluate Formula" tool since you don't need to go through all calculations to find the issue..
- Enter Edit mode: Double-press with left mouse button on the cell or press F2 to enter Edit mode for the formula.
- Select part of the formula: Highlight the specific part of the formula you want to evaluate. You can select and evaluate any part of the formula that could work as a standalone formula.
- Press F9: This will calculate and display the result of just that selected portion.
- Evaluate step-by-step: You can select and evaluate different parts of the formula to see intermediate results.
- Check for errors: This allows you to pinpoint which part of a complex formula may be causing an error.
The image above shows cell reference B6 converted to hard-coded value using the F9 key. The FACT function function requires a numerical value, which is not the case in this example. We have found what is wrong with the formula.
Tips!
- View actual values: Selecting a cell reference and pressing F9 will show the actual values in those cells.
- Exit safely: Press Esc to exit Edit mode without changing the formula. Don't press Enter, as that would replace the formula part with the calculated value.
- Full recalculation: Pressing F9 outside of Edit mode will recalculate all formulas in the workbook.
Remember to be careful not to accidentally overwrite parts of your formula when using F9. Always exit with Esc rather than Enter to preserve the original formula. However, if you make a mistake overwriting the formula it is not the end of the world. You can “undo” the action by pressing keyboard shortcut keys CTRL + z or pressing the “Undo” button
6.3 Other errors
Floating-point arithmetic may give inaccurate results in Excel - Article
Floating-point errors are usually very small, often beyond the 15th decimal place, and in most cases don't affect calculations significantly.
'FACT' function examples
I discussed the difference between permutations and combinations in my last post, today I want to talk about two kinds […]
Functions in 'Math and trigonometry' category
The FACT function function is one of 62 functions in the 'Math and trigonometry' category.
How to comment
How to add a formula to your comment
<code>Insert your formula here.</code>
Convert less than and larger than signs
Use html character entities instead of less than and larger than signs.
< becomes < and > becomes >
How to add VBA code to your comment
[vb 1="vbnet" language=","]
Put your VBA code here.
[/vb]
How to add a picture to your comment:
Upload picture to postimage.org or imgur
Paste image link to your comment.
Contact Oscar
You can contact me through this contact form