The standard way a math problem is asked is to give a certain amount of information and ask the student to supply information that hasn't been explicitly given, but that can be deduced. For example, if we have the equation p + q = 1, giving the value of either variable is sufficient to find the other. Similarly, in the equation Area = 1/2(Base x Height), any two out of three variable values given is enough to suss out the third. In the first situation, we would say there are two pieces of information and one degree of freedom. In the area formula, there are three pieces of information and two degrees of freedom. In both, there are n pieces of information and n-1 degrees of freedom.
The degrees of freedom in a problem is not always n-1. Consider a contingency table, a grid of numbers in rows and columns that includes a last row and a bottom column of sums. Here is a 2x2 contingency table, for example.
The grid has nine positions, but clearly enough if the values of the four variables are given, the other five sums are easily determined. In fact, if an instructor gives out numbers and the student is allowed to fill in the quantities that can be figured out step by step, there are four degrees of freedom in this table. For example, the following table could be filled out using addition and subtraction.
So a contingency table adds an extra row and an extra column but the degrees of freedom will always be the number of elements of the original grid without the added parts.
Some problems don't always have a fixed degree of freedom. Take Sudoku, for example. Sometimes, the easy problems actually give you information you could have figured out by yourself, and even two difficult problems might not have the same quantity of filled in symbols.
Let me give two simple examples using 4x4 Sudoku. The rules are these. There are four symbols, A, B, C and D, and each symbol must appear in every row and every column, as well as in every 2x2 grid in each corner, shown here by giving the corners different colors, black, green, red and blue.
Here is a 4x4 Sudoku with seven degrees of freedom. If any information was taken away, there would not be a unique answer.
A B C _
C _ A _
D _ B _
_ _ _ _
On the other hand it is possible to produce a 4x4 Sudoku with four degrees of freedom. Here is an example of that.
A _ _ _
_ _ B _
D _ _ _
_ _ _ C
Degrees of freedom is a concept used in a lot of parts of math. Most students first see it in statistics.
Answers in the comments.