Checking if 3 numbers are an arithmetic progression
The requirements are that (1) b - a == c - b and that (2) a &lt; b &lt; c, except when equalOk is true, in which case (3) a &lt;= b &lt;= c. If (1) is true, then it is sufficient to just check a &lt; b for (2) and a &lt;= b for (3).

private bool InOrderEqual(int a, int b, int c, bool equalOk) {
    if (b - a != c - b) return false; // (1)
    if (equalOk) return a &lt;= b; // (3)
    return a &lt; b; // (2)
}


Originally, equidistance was not an explicit requirement.

Original answer:

The requirements are that a &lt; b &lt; c, except when equalOk is true, in which case a &lt;= b &lt;= c. There's no need for anything more complex than this:

private bool InOrderEqual(int a, int b, int c, bool equalOk) {
    if (equalOk) return a &lt;= b &amp;&amp; b &lt;= c;
    return a &lt; b &amp;&amp; b &lt; c;
}