There are other answers there, but I wanted to give an answer in terms of the velocity of the spacecraft, the velocity of the planet, and the surface gravity of the planet.
TL;DR The largest increase in speed possible in a gravity assist is
$$ \frac{2sgr}{gr + s^2} $$
where $s$ is the initial speed of the spacecraft relative to the planet, $r$ is the radius of the planet, and $g$ is the surface gravity of the planet.
A gravitational slingshot is when a spacecraft uses the gravity of a planet to gain speed relative to the solar system. In the reference frame of the planet, the spacecraft flies by it in a hyperbolic trajectory, with the same speed entering and leaving. Because the planet is moving, the speed of the craft relative to the solar system changes. This is demonstrated in the following gif from wikipedia.

Let's analyze the motion of the spacecraft relative to the planet. We place the center of the hyperbola on the origin, and the focus of the hyperbola is the planet's center, which we place at $(c, 0)$.
Since the speed is the same long before as long after the craft leaves the planet, the maximum velocity change comes if the change in angle is maximized, which happens when the craft just skims the planets surface. Thus, if the planet's radius is $r$, the vertex of the hyperbola is at $(c - r, 0)$.
The equation of the hyperbola is of the form
$$\frac{x^2}{a^2} - \frac{y^2}{b^2} = 1$$
with $a = c - r$, and $b^2 = c^2 - a^2$.

Now, the change in velocity of the craft with respect to the planet is twice the initial $x$ component of the velocity, or $2 s \frac{a}{c}$. To put this in terms of the physical properties of the planet and initial speed, we will analyze the gravitational acceleration at the vertex.
Let $s$ be the speed of the craft in the limit long before the craft reaches the planet. Initially, the craft travels at speed $s$ along the asymptote $y = \pm \frac{b}{a} x$. This asymptote is distance $b$ from the focus. Thus, the line segment between the craft and the planet sweeps out area at the rate $\frac{1}{2} b s$. By Kepler's Second law, the spacecraft sweeps out area at the same rate when it is at the vertex of the hyperbola, a distance of $c-a = r$ from the planet. So the speed $s_0$ of the craft at this time is given by $\frac{1}{2} b s = \frac{1}{2} r s_0$, which yields $s_0 = \frac{b}{r} s$.
Differentiating the equation for the hyperbola twice with respect to time, we get
$$ \left(x \frac{d^2x}{dt^2} + \left(\frac{dx}{dt}\right)^2\right) \frac{1}{a^2} = \left(y \frac{d^2y}{dt^2} + \left(\frac{dy}{dt}\right)^2\right) \frac{1}{b^2} $$
At the vertex, we have $x = a, \frac{dx}{dt} = 0, y = 0, \frac{dy}{dt} = s_0$, and the gravitational acceleration is entirely in the $x$ direction, so $\frac{d^2x}{dt^2} = g$, and this becomes
$$ g = s_0^2 \frac{a}{b^2} $$
Or, substituting in our formula for $s_0$
$$ g = s^2 \frac{a}{r^2} $$
Rearranging gives us $a$, and thus $c$ and $\frac{a}{c}$, in terms of $g$, $s$, and $r$.
$$\frac{a}{c} = \frac{a}{a + r} = \frac{1}{1 + \frac{r}{a}} = \frac{1}{1 + \frac{s^2}{gr}} $$
So the change of velocity is
$$ \frac{2sgr}{gr + s^2} $$
in the $x$-direction. If this direction is almost the same as the direction as the spacecraft's initial direction in the solar system reference frame, then this change in velocity equates to an absolute increase in speed.