title: Write a program to generate the first n terms in the series --- 34,18,10,6,4,
body: <p>Input is <strong><em>n</em></strong> which is a single integer.<br>
  Output consists of the series separated by blank space.<br>
  Sample Input:<br>
  6<br>
  Sample Output:<br>
  34 18 10 6 4 3  </p>
  
  <p>For this program I had initially declared two variables and initialized them to 34 and 18 respectively. From there on it was easy to calculate the next values and keep printing them. But this was done assuming the series starts from only 34 and the series only consists of 6 terms. This output wasn't accepted as it may have not satisfied all the test cases.
  So I wrote the following program to find out series based on the value of <em>n</em> entered by the user whereas the program will find out where the series starts and calculate the series from there onward.</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  int main()
  {
      int a=34,b=18,n,i,sub=16;
      scanf("%d",&amp;n);
      if(n&gt;6)
      {
          for(i=0;i&lt;n-6;i++)
          {
              sub=sub*2;
              a=a+sub;
              b=b+(sub/2);
          }
      }
      printf("%d %d",a,b);
      for(i=0;i&lt;n-2;i++)
      {
          sub=sub/2;
          b=b-sub;
          printf(" %d",b);
      }
      return 0;
  }
  </code></pre>
  
  <p>This way I calculate what the first term of the series is and then start the pattern from there. But it is still not being accepted. Is there some way this code is not satisfying the test cases or is it supposed to be improved?</p>