here P1|P2|P3|......Pm processes are running each taking time quantum= w units and process switch is p seconds so we have to find when one process will get its time again so suppose there are 4 processes P1,P2,P3,P4
P1|P2|P3|P4|P1 to get when p1 will again get its chance let it n seconds
there are 4 switches happen and between first time execution and second time execution of P1 three processes spend quantum time
so in this case 4p+3w<=n
and now generalise it, it will be
mp+(m-1)w<=n
so $w<= \frac{n-mp}{m-1}$