I'm doing a repeat loop in connection with a question that I am working on: "Set i to be 1. Write a repeat() loop which doubles i until i is greater than 100. What value is i now?"
Here's my code so far
i <- 1
repeat{
print(i)
i <- i*2
if(i > 100) break
}
I ran the above code and got the following output
[1] 1
[1] 2
[1] 4
[1] 8
[1] 16
[1] 32
[1] 64
Now I am just wondering if the above code and output are right? If not, can anyone help me with this one and what am I doing wrong?