title: Gambling algorithm
body: <p>I have a hard time figuring out how to write a program in R.
  I am suppose to bet 1$ on red, if I win I get 1$ and bet again, if I lose I double my bet. The program supposed to run until I win 10$ or bet becomes greater than 100.
  Here is my code:</p>
  
  <pre><code>    W=0
      B=1
  
      for(i=sample(0:1,1)){
        B&lt;-1
        W&lt;-0
        while(W&lt;10 &amp; B&lt;=100){
          if(i=1){
            W&lt;-W+B 
            B&lt;-B
          }else{
            B&lt;-2*B
          }
          print(B)
        }
      }
  </code></pre>
  
  <p><code>i</code> determines if I lose or win. And I use <code>print(B)</code> to see the if program runs. At this point it doesn't, B just equals 1 no matter what.</p>