In triangle $ABC$, medians $\overline{AD}$ and $\overline{BE}$ are perpendicular.  If $AC = 22$ and $BC = 31$, then find $AB$.
We have that $D$ and $E$ are the midpoints of $\overline{BC}$ and $\overline{AC}$, respectively, so
\[\overrightarrow{D} = \frac{\overrightarrow{B} + \overrightarrow{C}}{2} \quad \text{and} \quad \overrightarrow{E} = \frac{\overrightarrow{A} + \overrightarrow{C}}{2}.\][asy]
unitsize(0.2 cm);

pair A, B, C, D, E;

B = (0,0);
C = (31,0);
A = intersectionpoint(arc(B,17,0,180),arc(C,22,0,180));
D = (B + C)/2;
E = (A + C)/2;

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

label("$A$", A, N);
label("$B$", B, SW);
label("$C$", C, SE);
label("$D$", D, S);
label("$E$", E, NE);
[/asy]

Also, $\overrightarrow{AD} \cdot \overrightarrow{BE} = 0$, or
\[\left( \overrightarrow{A} - \frac{\overrightarrow{B} + \overrightarrow{C}}{2} \right) \cdot \left( \overrightarrow{B} - \frac{\overrightarrow{A} + \overrightarrow{C}}{2} \right) = 0.\]Multiplying each factor by 2 to get rid of fractions, we get
\[(2 \overrightarrow{A} - \overrightarrow{B} - \overrightarrow{C}) \cdot (2 \overrightarrow{B} - \overrightarrow{A} - \overrightarrow{C}) = 0.\]Expanding the dot product, we get
\[-2 \overrightarrow{A} \cdot \overrightarrow{A} - 2 \overrightarrow{B} \cdot \overrightarrow{B} + \overrightarrow{C} \cdot \overrightarrow{C} + 5 \overrightarrow{A} \cdot \overrightarrow{B} - \overrightarrow{A} \cdot \overrightarrow{C} - \overrightarrow{B} \cdot \overrightarrow{C} = 0.\]Setting the circumcenter of triangle $ABC$ to be the origin, and using what we know about these dot products, like $\overrightarrow{A} \cdot \overrightarrow{B} = R^2 - \frac{c^2}{2}$, we get
\[-2R^2 - 2R^2 + R^2 + 5 \left( R^2 - \frac{c^2}{2} \right) - \left( R^2 - \frac{b^2}{2} \right) - \left( R^2 - \frac{a^2}{2} \right) = 0.\]This simplifies to $a^2 + b^2 = 5c^2$.

We are given that $a = 31$ and $b = 22$, so $5c^2 = 31^2 + 22^2 = 1445$, and $c = \boxed{17}$.