In the first line of the explanation why does M have to be less than min(i,j,k,N) and how are we removing the last mod N.??
we can observe that
a%b is less than a if a>=b
a%b=a if b>a
so…as we want the maximum value to be M…we can’t perform modulo operation to M with something greater than M as the value of M will be reduced. so it is optimal to choose i,j,k,N greater than M .
so if we want M to be as it is till the end…we want to perform modulo with something greater than M
as M%k=M if k>M