new; cls; t1=3; t2=17; dist={5,3,4}; /* rows(dist)+1 numbers between t1 and t2 with the min distance of dist */ up=t2-rev(cumsumc(0|rev(dist))); low=t1+cumsumc(0|dist); if not low<=up; errorlog "ERROR: Out of range."; else; x=low; print/lz x'; do while not x==up; x=recFDindex(x,up,dist); print/lz x'; endo; endif; proc recFDindex(x,up,dist); local dim,j; dim=rows(x); x[dim]=x[dim]+1; j=dim; do until j==0; if x[j]==up[j]+1; x[j-1]=x[j-1]+1; if x[j-1]/=up[j-1]+1; x[j-1:dim]=x[j-1]+cumsumc(0|dist[j-1:dim-1]); endif; endif; j=j-1; endo; retp(x); endp;