Margalit and Schleimer found examples of roots of the Dehn twist t
C
about a nonseparating curve C in a closed orientable surface, that is, homeomorphisms h such that h
n = t
C
in the mapping class group. Our main theorem gives elementary number-theoretic conditions that describe the n for which an n
th root of t
C
exists, given the genus of the surface. Among its applications, we show that n must be odd, that the Margalit-Schleimer roots achieve the maximum value of n among the roots for a given genus, and that for a given odd n, n
th roots exist for all genera greater than (n − 2)(n − 1)/2. We also describe all n
th roots having n greater than or equal to the genus.