Let us take a simple example of 4 processes P1 , P2 , P3 and P4 . Here n=4
Consider P1 || P2 || P3 || P4 || P1 || P2 || ..... will be the round robin scheduling order.
Now acc to the question the context swtich time is S , here context is shown by " || "
and time quantum is " Q "
and T is the time taken by a process to again get the CPU after scheduling once .
if we see our scheduling pattern P1 || P2 || P3 || P4 || P1 || P2 ||
P1 gets the CPU again after 4 ( = n) context switch and 3 ( =n-1) time quantum.
So 4S + 3Q <= T
In general, where n is the process count , this becomes
nS + (n-1) Q <= T
(n-1)Q <= T - nS
=> Q <= (T- nS ) / ( n-1)