I'm reading An Improved Monte Carlo Factorization Algorithm by Richard P. Brent. I'm not sure I'm understanding some of the notation correctly. 
To my understanding $x_0$ is an arbitrary starting point and is often 2. Is this correct?
I don't understand the syntax involving repeat, for and do. For example does everything on the repeat line get done repeatedly until the until condition is met? It doesn't make sense to me repeatedly setting x to y.
repeat ... untilforms a block -- every after therepeatis to be repeateduntilthe condition specified byuntilis met. For the firstrepeatthe last line of the block is $G = \mbox{GCD}(q,N); k = k+m$. Forrepeat...untileverything in the block is executed at least once as theuntilcondition is only checked when it is met.for...doworks the same way, though here if theforstatement needs more than one linebegin...endis being used to contain all the work that thefor...doneeds to do. So in your firstfor...doeverything in on one line, but for the second there is a block of two lines following that are affected.Keep an eye on the indentation: things indented to the same level are expected to be in the same block. So the
for...doin the first place is inside therepeat...untiland will be executed by therepeatuntil theuntilcondition is met.