It is clear that x∈Q and x>0.
On the other hand, if x has such a representation, then from the inequalities
a1a2…an1≤a2a3…an1a2a3…ana1≤a2a3…ana2−1=a3a4…an1−a2a3…an1an−1anan−2≤an−1anan−1−1=an1−an−1an1anan−1≤anan−1=1−an1,
we get x≤1−an1, hence x∈(0,1]. We note that x=1 can be represented in this form by considering n=1 and a1=1.
If x=qp∈(0,1), where p and q are positive integers, p<q, then we can write
x=x⋅1=qp(1⋅2…p1+2⋅3…p1+3⋅4…p2+pp−1),
and we can consider n=p, a1=1, a2=2, …, ap−1=p−1, ap=q.
The desired numbers are the elements of the set Q∩(0,1].