title: Checkdigit algorithm Luhn mod N vs simple sum
body: <p>Do you know why the <a href="http://en.wikipedia.org/wiki/Luhn_mod_N_algorithm" rel="nofollow noreferrer">Luhn mod N algoritm</a> in order to create the check digit performs a sum by doubling the value of each even placed char instead of perfoming a simple sum of all chars?</p>
  
  <p>In pseudo-code words:</p>
  
  <p>given:</p>
  
  <pre><code>var s = "some string i want to create check digit";
  </code></pre>
  
  <p>do you know why Luhn mod N does basically this:</p>
  
  <pre><code>for(i from s.length-1 to 0)
     if(i is even)
        checkdigit += chr2int(s[i]) * 2;
     else
        checkdigit += chr2int(s[i]);
  </code></pre>
  
  <p>instead of simply doing a sum</p>
  
  <pre><code>for(i from s.length-1 to 0)
     checkdigit += chr2int(s[i]);
  </code></pre>
  
  <p>they can still both terminate with a <code>mod</code> operation to make the checkdigit fit into one char</p>
  
  <pre><code>return int2chr( chr2int('a') + (checkdigit mod 25) );
  </code></pre>
  
  <hr>
  
  <p><em>As a side note to this question, to whom it may be interested in a graphic representation of the Luhn algorithm that makes it even more simple to understand:</em></p>
  
  <p><img src="https://i.stack.imgur.com/Cenb3.png" alt="enter image description here"></p>
  
  <p><em>Actually this one is the original Luhn algorithm that does not even needs to use MOD function.</em></p>