title: How to generate the nth numbers containing only 2 types of digits?
body: <p>We define a <strong>special number</strong> as a number containing only 4s and 7s.</p>
  
  <p>Let's see examples: <code>447</code> , <code>477</code> , <code>444</code> and <code>777</code> are <strong>special numbers</strong> while <code>407</code> isn't.</p>
  
  <p>I need help to understand what is the <strong>law/rule</strong> to generate the <code>Nth</code>  special number. </p>
  
  <p>I tried the code below but it didn't work</p>
  
  <pre><code>int x[2000];
  int k=0;
  
  void dfs( int a ) {
    if(k==1021)
      return;
    x[k++]=a;
    dfs(a*10+4);
    dfs(a*10+7);
  }
  
  dfs(4);
  dfs(7);
  </code></pre>
  
  <p>Any solution or idea about how to do it  ? </p>