7. If we denote A(p,q,n)=∣p˙+jq∣i,j⩾0,i+j⩽n, then the number of elements in A(p,q,n) is
∣A(p,q,n)∣={2(n+1)(n+2),2p(2n−p+3),n<p;n⩾p.
According to the definition, we have
A(p,q,n)\A(p,q,n−1)={ip+(n−i)q∣i=1,2,⋯,n}.
Notice that ip+(n−i)q=p(i+q)+q(n−p−i), and
(i+q)+(n−p−i)=n−p+q⩽n−1, then
ip+(n−i)q∈A(p,q,n−1)⇔n−p−i⩾0.
Therefore, A(p,q,n)\A(p,q,n−1)
={∣p˙+(n−i)q∣i=n−p+1,n−p+2,⋯,n∣,n⩾p;∣p˙+(n−i)q∣i=0,1,⋯,n∣,n<p.
Let an=∣A(p,q,n)∣, then
an−an−1={p,n+1,n⩾p;n<p.
Noting that a0=1, for n<p, we have
an=a0+(a1−a0)+⋯+(an−an−1)=1+2+⋯+(n+1)=2(n+1)(n+2);
Therefore, for n⩾p, we have
an=ap−1+(ap−ap−1)+⋯+(an−an−1)=ap−1+(n−p+1)p=2p(2n−p+3).