18/07/05 22:46:00.14 bn3tqJqU.net
>>615
x=c(0,1,2) # 01132
insert <- function(x){
n=length(x)
y=numeric()
z=NULL
for(i in 1:n){
y[i]=x[i]+x[i+1]
z=append(z,c(x[i],y[i]))
}
return(z[-length(z)])
}
pyramid <- function(n,x){
zz=list()
zz[[1]]=insert(x)
if(n==1) return(zz)
for(i in 2:n){
zz[[i]]=insert(zz[[i-1]])
}
return(zz)
}
と準備して