 <p>Let's see what actually (i + 7) % 10 do:</p> <pre><code>0 = 7 1 = 8 2 = 9 3 = 0 4 = 1 5 = 2 6 = 3 7 = 4 8 = 5 9 = 6 </code></pre> <p>As you can see there's definitely quite obvious pattern. So in order to decode our original digit back we have to do</p> <pre><code>(i + 3) % 10 </code></pre>