Finding the average of two unsigned integers without overflow
<p><pre><code>    There’s another algorithm that doesn’t depend on knowing which value is larger, the U.S. patent for which expired in 2016:

    unsigned average(unsigned a, unsigned b)
    {
        return (a / 2) + (b / 2) + (a & b & 1);
    }
</code></pre>
There's no way that should be patentable.