I know that the area of a rectangle is length times width, and that the perimeter of a rectangle is 2 times the sum of the length and width. So, if I let L be the length and W be the width, I have two equations: A = LW and P = 2(L + W). I want to maximize A, but I also have a constraint on P: it has to be 40 feet. So, I can substitute P = 40 into the second equation and get 40 = 2(L + W), which simplifies to 20 = L + W. Now, I can use this equation to eliminate one of the variables in the first equation. For example, I can solve for W in terms of L: W = 20 - L. Then, I can plug that into the first equation and get A = L(20 - L). This is a quadratic function of L, and I can use calculus or algebra to find its maximum value. If I use calculus, I can take the derivative of A with respect to L and set it equal to zero: A' = 20 - 2L = 0. This gives me L = 10. Then, I can plug that back into the equation for W and get W = 10 as well. So, the maximum area occurs when L = W = 10, which means the rectangle is actually a square. The area of the square is 10 times 10, which is 100 square feet. 
Given 40 feet of fencing, what is the greatest possible number of square feet in the area of a rectangular pen enclosed by the fencing?