Solution:
Equivalently, a k-representation is given by a sequence ap,…,aq, for some p<q, such that
i=p∑qai=i=p∑qaiki.
We first show existence. Let the representation of n−1 in base k be given by ∑i=0raiki=n−1. Let l=∑i=1rai(ki−1+ki−2+⋯+1). Now we extend the sequence {ai} by letting ai=k−1 if −l+1≤i≤−1 and a−l=k. We claim that a−l,…,ar−1,ar is a k-representation of n. Indeed,
i=−l∑raikii=−l∑rai=(n−1)+(i=−l∑−1(k−1)ni)+k−l=(n−1)+(k−1)k−11−k−11−k−l+k−l=n=(i=0∑rai)+l(k−1)+1=(i=0∑rai)+(i=1∑rai(ki−1))+1=(i=0∑raiki)+1=n
Now suppose there is another k-representation {bi} of n; then ∑bi=∑biki=n. This implies that ∑ci=∑ciki=0 where ci=ai−bi. The following claim specifies all possibilities of {ci}.
Claim: Suppose that ∑i=pqciki=0, where ci,p,q∈Z,p<q, and ci∈[−k,k]. Then the sequence {ci} must be the concatenation of subsequences of the form
±(1,1−k,1−k,…,1−k,−k)
possibly with 0's in between.
Proof. If ci is not the zero sequence, then without loss of generality, we may assume cq>0.
Since ∑i=pqciki=0, we have
∣cqkq∣=∣cq−1kq−1+…+cpkp∣≤kq+kq−1+…+kp+1<k−1kkq≤2kq
so cq=1. Now we have
kq+cq−1kq−1+…+cpkp=0
This means (k+cq−1)kq−1+…+cpkp=0. Hence, as above,
∣(k+cq−1)kq−1∣=∣cq−2kq−2+…+cpkp∣<2kq−1
Therefore, ∣k+cq−1∣<2, which means cq−1=−k or −k+1.
If cq−1=−k, then cqkq+cq−1kq−1=0, and we get a subsequence (1,−k).
If cq−1=−k+1, then cqkq+cq−1kq−1=kq−1. Thus
kq−1+cq−2kq−2+…+cpkp=0
which has the exact same form as (1). We can then repeat this procedure to obtain a subsequence (1,1−k,1−k,…,1−k,−k).
Once we have such a subsequence, the terms in the sum ∑i=pqciki=0 corresponding to that subsequence sum to 0, so we may remove them and apply the same argument.
We now consider the cases.
If the base k representation of n−1 contains no 0's, then ai=0 so it is impossible to have ci=ai−bi=−k. On the other hand, we know that ci is composed of subsequences of the form ±(1,1−k,1−k,…,1−k,−k). Therefore, if {ci} is not the zero sequence, then the fact that ∑ci=0 implies that we must have both a subsequence (1,1−k,1−k,…,1−k,−k) and a subsequence −(1,1−k,1−k,…,1−k,−k), meaning that there exists i for which ci=−k, contradiction.
If the base k representation of n−1 contains a 0, then picking the largest i such that ai=0, we can change ai to k and ai+1 to ai+1−1, and append a (1,−k) to the end of the sequence. This yields another k-representation of n, so a k-representation of n is unique if and only if the base k representation of n−1 contains no 0's, as desired.