Generalizations of Fermat's little theorem via group theory