I have a vector a and want to multiply each element recursively with b, without using a loop.
a
b
a <- rep(0, 10) a[1] <- 1 b <
In general, you can't do this without an explicit loop. In this specific case, you can use the implicit loop provided by cumprod:
cumprod
a <- rep(2, 10) a[1] <- 1 cumprod(a) # [1] 1 2 4 8 16 32 64 128 256 512