For general purpose of recursion formula, you could do it like this: > make.vector <- function(w, n, a, b) c(w, sapply(1:(n-1), function(x) w <<- w > * a / (b + x))) > make.vector(w = 1, n = 4, a = 24, b = 1) [1] 1 12 96 576
On Fri, Feb 26, 2010 at 11:23 PM, <khaz...@ceremade.dauphine.fr> wrote: > Hello all, > > I want to define a vector like w[k+1]=w[k]*a/(b+k) for k=1,...,N-1 without > use loop. Is it posible to do in R? > > Regards > > khazaei > > ______________________________________________ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.