In triangle $ABC$, $AB = 5$, $BC = 8$, and the length of median $AM$ is 4.  Find $AC$.
Since $BC = 8$ and $M$ is the midpoint of $BC$, $BM = CM = 4$.  But $AM = 4$, so $M$ is the circumcenter of triangle $ABC$.  Furthermore, $BC$ is a diameter of the circle, so $\angle BAC = 90^\circ$.

[asy]

unitsize(2 cm);

pair A, B, C, M;

A = dir(110);

B = (-1,0);

C = (1,0);

M = (0,0);

draw(A--B--C--cycle);

draw(A--M);

draw(Circle(M,1));

label("$A$", A, dir(90));

label("$B$", B, SW);

label("$C$", C, SE);

dot("$M$", M, S);

[/asy]

Then by Pythagoras on right triangle $ABC$, $AC = \sqrt{BC^2 - AB^2} = \sqrt{8^2 - 5^2} = \sqrt{64 - 25} = \boxed{\sqrt{39}}$.