new; cls; t1=2; t2=18; dim=3; mindist=7; /* 3 numbers between t1 and t2 with the min distance of 7 */ N=t2-t1+1-(dim-1)*mindist; if N<1; errorlog "ERROR: Out of range."; else; low=t1+seqa(0,mindist,dim); up=low+N-1; x=low; print/lz x'; do while not x==up; x=recDindex(x,up,mindist); print/lz x'; endo; endif; proc recDindex(x,up,mindist); 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]+seqa(0,mindist,dim+1-(j-1)); endif; endif; j=j-1; endo; retp(x); endp;