title: What is the fastest way to check for duplicate digits of a number?
body: <p>Let's say I want to check if a number n = 123 has duplicate digits. I tried:</p>
  
  <pre><code>#include &lt;iostream&gt;
  
  using namespace std;
  
  int main() {
      int n = 123;
      int d1 = n % 10;
      int d2 = ( n / 10 ) % 10;
      int d3 = ( n / 100 ) % 10;
      if( d1 != d2 &amp;&amp; d1 != d3 &amp;&amp; d2 != d3 ) {
          cout &lt;&lt; n &lt;&lt; " does not have duplicate digits.\n";
      }
  }
  </code></pre>
  
  <p>Is there any faster solution to this problem?  </p>
  
  <p><strong>Update</strong><br>
  Sorry for being unclear. The code above was written in C++ only for description purpose. I have to solve this problem in TI-89, with a number of 9 digits. And since the limitation of memory and speed, I'm looking for a fastest way possible.  </p>
  
  <p>TI-89 only has several condition keyword: </p>
  
  <ul>
  <li>If</li>
  <li>If ... Then</li>
  <li>when( </li>
  <li>For ... EndFor</li>
  <li>While ... EndWhile</li>
  <li>Loop ... EndLoop</li>
  <li>Custom ... EndCustom</li>
  </ul>
  
  <p>Thanks,<br>
  Chan</p>