help!! I can’t do the iteration

I want to make the panjer model for the Poisson but my problem is that I do not know how to iterate for the previous ones ,ie for x=2 it comes out but for x=3 no, I need to save the result of x=2 to add it to x=3 and so on,here is the code I did.

if (x>0){
g<- numeric(x+1)
gf<- numeric(x)
for (i in 1:x){
g[i+1] <- sum(gf)
else {print(dpois(0,lamda))}

A reprex with the highlighted statement's syntax corrected is required.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.