Arduino mega 2560

Is it possible to control 24 DC motor speed at the same time using Arduino mega 2560? if yes then can anyone give me an idea how to write a code for it ?

How are the motors powered? Does each one have a driver with it?
Really need more info to provide some help.

can anyone give me an idea how to write a code for it ?

I do not think we can help much until we know what you want to do.

The short answer is write code for 1 motor, then replace the variables and constants with arrays
of size 24, and add for loops and indices into the code.

Assuming the motors are to be separately controlled. If running in concert you may be able to
share driver electronics.