If a=1, the identity of the problem holds regardless of how other positive integers n,p,q,r are chosen. So, we assume that a≥2 in the sequel. Since the given identity is symmetric in p,q,r, we may assume that p≤q≤r holds.
We can rewrite the given identity in the form
an=ap+q+r−(ap+q+ap+r+aq+r)+(ap+aq+ar).
Since a≥2, we have ap+q>ap, aq+r>aq, ap+r>ar. This together with the fact that ap+aq+ar>0 gives us
ap+q+r>an>ap+q+r−(ap+q+ap+r+aq+r).
From the left half of the inequality above, we see that n≤p+q+r−1 and using this we get from the right half of the inequality above that ap+q+r−1>ap+q+r−(ap+q+ap+r+aq+r), which simplifies to
a−1+a−p+a−q+a−r>1.
Because of the fact that 1≤p≤q≤r, we have a−1≥a−p≥a−q≥a−r and since the sum of these 4 numbers is greater than 1 as we saw above, we get a−1>41. Thus we have a<4 and since a≥2, we must have either a=2 or a=3.
(1) Consider the case when a=3:
In this case we have 3−p+3−q+3−r>1−3−1=32 so that 3−p>92, and therefore, p=1. We then get 3−q+3−r>31, which in turn implies 3−q>61, and therefore, q=1. Now from p=q=1, we conclude from the given identity that 3n=4⋅3r−3 must hold. Since 4⋅3r<9⋅3r=3r+2, we must have n≤r+1. Consequently, we must have 3r+1≥4⋅3r−3, which simplifies to 3r≤3. Therefore, r=1 must hold. Thus we see that if a=3, then p=q=r=1 must hold and then the given identity forces n to satisfy 3n−1=(3−1)3, from which we get n=2. Thus we conclude that (3,2,1,1,1) is the unique solution in the case (1).
(2) Consider the case when a=2:
In this case, we have 2−p+2−q+2−r>21, which implies 2−p>61. Therefore, we must have either p=1 or p=2.
* Case when p=2:
In this case, we have 2−q+2−r>41 so that 2−q>81 and combining with the fact q≥p=2 we get q=2 as well. Then, we see that the given identity takes the form 2n=9⋅2r−8. From 9⋅2r<16⋅2r=2r+4 we get 2r+3≥9⋅2r−8, which simplifies to 2r≤8. So, we must have r=2 or r=3. Checking each of these cases, we can conclude that (a,n,p,q,r)=(2,6,2,2,3) is the unique solution in this case.
* Case when p=1:
In this case the given identity takes the form 2n=2q+r−2q−2r+2. Since the right side of this equality is less than 2q+r, we must have 2q+r−1≥2q+r−2q−2r+2, which reduces to the inequality 2q+r−1+2≤2q+2r, from which we get, as 2q+2r≤2r+1, that 2q+r−1<2r+1. Hence, q+r−1<r+1 and we get q=1. The given identity now reduces, as p=q=1, to the equality 2n=2r, so we must have n=r, which can be any positive integer. Thus the solution in this case takes the form (a,n,p,q,r)=(2,k,1,1,k), where k is an arbitrary positive integer.
Summarizing the arguments given above, we can write down all the quintuples (a,n,p,q,r) satisfying the given identity as follows:
* a=1 and n,p,q,r can be arbitrary positive integers.
* (a,n,p,q,r)=(3,2,1,1,1).
* (a,n,p,q,r)=(2,6,2,2,3) and its variants obtained by permuting p,q,r.
* (a,n,p,q,r)=(2,k,1,1,k) where k is an arbitrary positive integer and their variants obtained by permuting p,q,r.