My voting is in a closed form, as suggested by @bdecaf (because it would annoy your teacher):
vast = function(n) round(((5 + sqrt(5)) / 10) * (( 1 + sqrt(5)) / 2) ** (1:n - 1))
, , :
vast=function(n){
vast=vector()
vast[1]=1
vast[2]=1
for(i in 3:n){vast[i]=vast[i-1]+vast[i-2]}
return(vast)
}
- , , , , . -, , for R, , . , :
vast=function(n){
x = c(1,1)
for(i in 3:n) x[i] = x[i-1] + x[i-2]
return(x)
}
, , , . - -, , .
: @Carl Witthoft, , , , :
vast=function(n) {
x = numeric(n)
x[1:2] = c(1,1)
for(i in 3:n) x[i] = x[i-1] + x[i-2]
return(x)
}