Let $n$ be a positive integer. Each of Tom and Jerry has some coins. If Tom gives $n$ coins to Jerry, then Jerry will have 2 times as many coins as Tom. If instead Jerry gives 2 coins to Tom, then Tom will have $n$ times as many coins as Jerry. Find the sum of all possible values of $n$.
I simplified the question to 2 equations where $t$ is Tom's initial sum of coins and $j$ is jerry's initial sum and $t,n,j$ are positive integers.
$2(t-n)=j+n$
$n(j-2)=t+2$
I managed to get $3(t+1)=(j+1)(n+1)$ from those 2 equations but I don't know what to do next hints, suggestions and solutions would all be appreciated
taken from the 2016 TIMC https://chiuchang.org/wp-content/uploads/sites/2/2018/01/2016_TIMC_Keystage_III_Individual_Final.x17381.pdf
Eliminating $j$ from the simultaneous equations gives $$t=\frac{7n+4}{2n-1}.$$
Then $2n-1$ is a factor of $2(7n+4)-7(2n-1)=15$.
Therefore $2n-1$ is one of $\{1,3,5,15\}$ and $n$ is one of $\{1,2,3,8\}$.
All these values of $n$ give valid solutions-the possible values of $(n,j,t)$ being $(1,11,7),(2,6,6), (3,5,7), (8,4,14)$
The total of $n$ is therefore $14$.