Length of a spring under its own weight

1. The problem statement, all variables and given/known data
I was thinking over lunch today about this old problem from intro physics but I can't remember whether or not this is the correct solution.

What is the final length L of a spring of mass M and spring constant k, initially of length L0 after it is left to hang under its own weight?

2. Relevant equations

3. The attempt at a solution
Divide the unstretched spring into infinitesimal segments dl. Each of these segments will stretch an infinitesimal distance dx under the weight of an infinitesimal mass dm by the relation g dm = k dx. Let [tex]\lambda[/tex] be the linear density of the spring, so that [tex]dm = \lambda \,dl[/tex]. Then,

I'm no student of the calculus, but your solution is identical to the case where the spring is massless and its weight is concentrated at the far end. That doesn't sound right. I believe your extension X should be 1/2 of your calculated value, i.e. X =Mg/2k. Comments welcome.

1. The problem statement, all variables and given/known data
I was thinking over lunch today about this old problem from intro physics but I can't remember whether or not this is the correct solution.

What is the final length L of a spring of mass M and spring constant k, initially of length L0 after it is left to hang under its own weight?

2. Relevant equations

3. The attempt at a solution
Divide the unstretched spring into infinitesimal segments dl. Each of these segments will stretch an infinitesimal distance dx under the weight of an infinitesimal mass dm by the relation g dm = k dx. Let [tex]\lambda[/tex] be the linear density of the spring, so that [tex]dm = \lambda \,dl[/tex]. Then,