TITLE: What values of $n$ is $A=\frac{a_1}{a_2}+\frac{a_2}{a_3}+\cdots +\frac{a_{n-1}}{a_n}+\frac{a_n}{a_1}$ an integer?
QUESTION [6 upvotes]: Suppose $a_i\in \mathbb{N} $ such that $a_i\ne a_j$ and $\displaystyle\frac{a_i}{a_{i+1}}\ne \frac{a_j}{a_{j+1}}~$ for $i \ne j$ $($take $a_{n+1}=a_1)$ and $\displaystyle A=\frac{a_1}{a_2}+\frac{a_2}{a_3}+\cdots +\frac{a_{n-1}}{a_n}+\frac{a_n}{a_1}$.
Then for what values of $n\ge  2$ can $A$ be an integer?

I  found that if $a_i=(n-1)^i$ then $A$ is a integer but I realised that this  violates the condition $\displaystyle\frac{a_i}{a_{i+1}}\ne \frac{a_j}{a_{j+1}}~$. It was easy to prove that $A$ is not an integer  for $n=2$, but I was stuck for the cases where for $n>2$. I then I plugged in some values for $a_i$ but for $n>2$ but I found no solution.
Intuitively I think there is no solution but I am unable to prove it. Any help would be appreciated.
Edit-1: As pointed out by @WillJagy it is possible for $n=3,4,5$. So can we actually prove it is true for $n>6$ or are there some $n>6$ for which it isn't true?
Edit-2: I was able to find a solution for $n=5$ from a solution for $n=4$.
$$~~~~~~~~~~\frac{6}{4} + \frac{4}{3} + \frac{3}{1} + \frac{1}{6}  = 6$$
$$\implies \frac{2}{4} + \frac{4}{3} + \frac{3}{1} + \frac{1}{6}  = 5$$
$$\implies \frac{6}{2} +\frac{2}{4} + \frac{4}{3} + \frac{3}{1} + \frac{1}{6}  = 8$$
But I could not find a solution for $n=6$ from a solution for $n=5$  because when I rewrite  $\frac{4}{3} =1+\frac{1}{3}$, the $1$ in the numerator of $\frac{1}{3}$ is used by another $a_i$. I don't know whether we can prove by induction. Any suggestions is welcome.

REPLY [3 votes]: I guess you do not want any ratio $a_i/a_{i+1}$ to be an integer, otherwise trivial solutions can be produced.
For $n=3$, a solution can be produced as already seen in the answers.
We will use Egyptian fractions to prove that there always exists a sequence of such $a_i$'s for $n\gt 3$
$$1=\frac 12+\frac 13+\frac 16$$
We can break the last unit fraction $\dfrac 16$ using the fact that $\dfrac 1m=\dfrac 1{m+1}+\dfrac 1{m(m+1)}$
In this way, you can create an Egyptian fraction representation (with distinct unit fractions) for $1$ of arbitrary length, ie, for any $n\gt 3$, there exist a sequence of distinct $p_i (\neq 1)$'s ($i=1...(n-1)$) such that $1=\displaystyle\sum_1^{n-1}\frac 1{p_i}$
All that is left is to define our $a_i$'s in a suitable way. We define $a_1=1$ and $a_{i+1}=a_ip_i$ for all $i=1...(n-1)$ so that all the $a_i$'s are distinct and $\dfrac{a_i}{a_{i+1}}=\dfrac 1{p_i}$ are distinct for all $i=1...(n-1)$ and sum up to $1$ and $\dfrac{a_n}{a_1}=a_n$ is an integer, so the resulting sum $A=a_n+1$
Examples:
$$\frac 12+\frac 26+\frac 6{36}+\frac{36}1=37\\ \frac 12+\frac 26+\frac 6{42}+\frac{42}{1764}+\frac{1764}1=1765$$
Here's a Tio.run link if you want to generate a sequence of $a_i$'s for any $n$, but beware that the $a_i$'s grow larger quite quickly due to the construction.

Hmm, then again, perhaps this answer also generates trivial solutions because $a_n/a_1$ is an integer. I'm unsure if I can fix that. I'll update if I can.