Let us assume that the distance is D, speed of the train is S and time taken by the train is t.
t is nothing but $\frac{D}{S}$
Statement 1: Had the speed been 6 km per hour more, it would have needed 4 hours less
$\frac{D}{S+6}=t-4$
$\frac{D}{S+6}=\frac{D}{S}-4$
$4=\frac{D}{S}-\frac{D}{S+6}$
$\frac{S+6-S}{S\left(S+6\right)}=\frac{4}{D}$
$\frac{6}{S\left(S+6\right)}=\frac{4}{D}$
$D=\frac{2S\left(S+6\right)}{3}$
Statement 2: Had the speed been 6 km per hour less, it would have needed 6 hours more
$\frac{D}{S-6}=t+6$
$D\left[\frac{1}{S-6}-\frac{1}{S}\right]=6$
$\frac{S-S+6}{S\left(S-6\right)}=6$
$D=S\left(S-6\right)$
Equating the two equations for distance,
$S\left(S-6\right)=\frac{2S\left(S+6\right)}{3}$
$3S-18=2S+12$
$S=30$
Hence the speed is 30 kmph
We know that the distance D = S(S - 6) = 30*24 = 720km