Why is a motor is a reverse function of generator?

from Faraday's laws its clear that when ever there is change in flux, an emf is produced. in a dc motor there are permanent magnets that produce a magnetic flux. If the shaft of the motor is rotated, which in tern rotates the coil that is placed in the magnetic field. Thus, changing the flux that cuts the coil. since there is change in flux an emf is induced.thus, a dc motor can be used as a generator.