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:
W=0
B=1
for(i=sample(0:1,1)){
B<-1
W<-0
while(W<10 & B<=100){
if(i=1){
W<-W+B
B<-B
}else{
B<-2*B
}
print(B)
}
}
i
determines if I lose or win. And I use print(B)
to see the if program runs. At this point it doesn't, B just equals 1 no matter what.