No. of ways for $(((n \mod i) \mod j) \mod k) \mod n$ Consider $3$ integers, $i, j, k$ all between $1$ and $m$, both exclusive. Consider
$$(((n \mod i)\mod j)\mod k)\mod n$$
where $n$ is another positive integer. Suppose the maximum value of the above expression in $L$. Find the number of ways to choose the triple $(i,j,k)$ so as to get $L$.
My try:- 
Since in the end we have $\mod n$, $L$ can be $n-1$ at max. But, the thing is if it can even achieve that value! For instance, if we take both $n$, $m$ to be $4$, I checked by hit and trial that $L$ will be $1$. This got me thinking, is there a general representation for these "concatenated" mods? I've no more idea on how to proceed. Even if a hint will do. Thanks :) 

A partial result in the case $n=m$. 
Take $i=j=k=p$ where $p$ is the smallest integer greater than $n/2$. Then the result is $n-p$, the greatest integer lower than $n/2$.
Furthermore, if $i \geq p$, then $n$ mod $i$ is less than $n-i \leq n-p$ so the final result is kot greater than $n-p$. 
If $i < p$, then $n$ mod $i$ is not greater than $p-1$ ($n$ odd) or $p-2$ ($p$ even) ie $n-p$. 
A more careful study should yield the equality cases (I think it is $i=p,n-p$ and $j,k \geq n-p$). 
