>>89
Your 'n' column is usually called R. Your 'd' column with the initial 1 removed is usually called S. The extra 1 in 'd' causes a shift in d2. Compare the stream of unique (d2-1) values, starting with d2=4, to the R sequence. This will tell you what d3 is and why it cannot have the simple pattern you ascribe to it in your cond. Where your table cuts off, after it stays on 6 for a while, d3 does not continue with 7.