title: Turkish Identity Number Verification
body: <p>How can I make sure that the given text is Turkish Identity Number? I have seen <a href="https://gist.github.com/onury/7a380f906b1eb46dc2f0bb089caf7d12" rel="nofollow noreferrer">js version here</a> and <a href="https://gist.github.com/canerbasaran/5935004" rel="nofollow noreferrer">phthon version here</a></p>
  
  <p>Also, posted a question couple of days ago for <a href="https://stackoverflow.com/questions/53554304/turkish-identity-number-verification-in-swift">swift version here</a>.</p>
  
  <p>Turkish Identity Verification is not checks only if its numeric, it has some other functions too. Let me be more clear, It is numeric and has 11 digits. For example Let assume that first 9 digits are represented by d, and the last ones represented by c:</p>
  
  <pre><code>Identity Number = d1 d2 d3 d4 d5 d6 d7 d8 d9 c1 c2
  </code></pre>
  
  <p>10th digit must be,</p>
  
  <p><code>c1 = ( (d1 + d3 + d5 + d7 + d9) * 7 - (d2 + d4 + d6 + d8) ) mod10</code></p>
  
  <p>11th must be,</p>
  
  <pre><code>c2 = ( d1 + d2 + d3 + d4 + d5 + d6 + d7 + d8 + d9 + c1 ) mod10
  </code></pre>
  
  <p>and it never starts with "0". For example, "87836910956" is a Turkish Identity Number.</p>
  
  <p>Now I have to use this validation in android/java.</p>