Characterization of power digraphs modulo $n$