title: Codechef long challenge
body: <p>Q-You are given an integer N. Consider the sequence containing the integers 1,2,…,N in increasing order (each exactly once). Find the length of the longest subarray in this sequence such that the bitwise AND of all elements in the subarray is positive.</p>
  <p>i tried the following code to solve the problem but it is not working can anyone tell why or give a test case where it fails</p>
  <pre><code>#include &lt;bits/stdc++.h&gt;
  using namespace std;
  
  int main()
  {
     int t,n,i,c;
  
     cin&gt;&gt;t;
  
     while (t--)
     {
         i = 1;
         cin&gt;&gt;n;
  
         while(i)
         {
             if(pow(2,i)&lt;n)
             {
                 i++;
             }
             else if (pow(2,i)==n)
             {
                 break;
             }
             else
             {
                 i--;
                 break;
             }
         }
        
         if(n-pow(2,i)+1&gt;pow(2,i)-pow(2,i-1))
         {          
             cout&lt;&lt;n-pow(2,i)+1&lt;&lt;endl;
         }
         else{
             cout&lt;&lt;pow(2,i)/2&lt;&lt;endl;
         }
     }
  }
  </code></pre>