  Finding the point in an algebraic variety that is closest to a given point is
an optimization problem with many applications. We study the case when the
variety is a Fermat hypersurface. Our formula for its Euclidean distance degree
is a piecewise polynomial whose pieces are defined by subtle congruence
conditons.
