title: Octave while/for statement -- what's wrong in a code?
body: <p>This is my Octave code</p>
  
  <pre><code>    for K= 1:10
      while ( p &lt; 1 )
          ceil(log2(K))  +  1/(1-(1-p)^K) %function
          p = p + sens;
          K
      endwhile;
   endfor
  
   K
  </code></pre>
  
  <p>and here is an output:</p>
  
  <pre><code>ans =  10.000
  K =  1
  ans =  5.0000
  K =  1
  ans =  3.3333
  K =  1
  ans =  2.5000
  K =  1
  ans =  2
  K =  1
  ans =  1.6667
  K =  1
  ans =  1.4286
  K =  1
  ans =  1.2500
  K =  1
  ans =  1.1111
  K =  1
  ans =  1
  K =  1
  K =  10
  </code></pre>
  
  <p>So, as you can see -- in inner <code>while</code> statement value of <code>K</code> is fixed to 1. What I am supposed to do to vary this value between 1 and 10. Why it is not working? I have no idea why this inner <code>while</code> statement is proceed only once.</p>
  
  <p>ANSWER: There should be p= initial_value after <code>for K=</code>...</p>