  Context. The mass and radius of a planet directly provide its bulk density,
which can be interpreted in terms of its overall composition. Any measure of
the radial mass distribution provides a first step in constraining the interior
structure. The fluid Love number $k_2$ provides such a measure, and estimates
of $k_2$ for extrasolar planets are expected to be available in the coming
years thanks to improved observational facilities and the ever-extending
temporal baseline of extrasolar planet observations.
  Aims. We derive a method for calculating the Love numbers $k_n$ of any object
given its density profile, which is routinely calculated from interior
structure codes.
  Methods. We used the matrix-propagator technique, a method frequently used in
the geophysical community.
  Results. We detail the calculation and apply it to the case of GJ 436b, a
classical example of the degeneracy of mass-radius relationships, to illustrate
how measurements of $k_2$ can improve our understanding of the interior
structure of extrasolar planets. We implemented the method in a code that is
fast, freely available, and easy to combine with preexisting interior structure
codes. While the linear approach presented here for the calculation of the Love
numbers cannot treat the presence of nonlinear effects that may arise under
certain dynamical conditions, it is applicable to close-in gaseous extrasolar
planets like hot Jupiters, likely the first targets for which $k_2$ will be
measured.
