Sum of the series of numbers consisting of AP and GP both. 
Find the sum of all the terms, if the first $3$ terms among $4$
positive $2$ digit integers are in AP and the last $3$ terms are in
GP. Moreover the difference between the first and last term is 40.

I have assumed four numbers to be $a,b,c\text{ & }d$ where  $a,b\text{ & }c$ are in AP and  $b,c\text{ & }d$ are in GP. 
Let $b= x$, then $a=x-k$ and $c=x+k$ where $k$ is the common difference of the AP. Also as per the question, $|a-d|=40$. This means that $d=a-40$ or $d=40+a$. One place that I am getting confused is here as to which relation should I take. How can we decide this?

Now if I take $d=40+a$ i.e. $d=40+x-k$, then I can say that ;
$(x+k)^2=x(40+x-k)$
$\Rightarrow x = \frac{k^2}{40-3k} \gt 0$
Now solving the above inequality, we get the range for $k$ to be $(-\infty,-8)\cup(5,\infty)$ but I don't know if this is helpful as I have to plug in the values of $k$ into the relation $x = \frac{k^2}{40-3k}$ and find out that value which can give a positive $2$ digit number.
Is my approach correct? Is there a better way to solve this? Also how to decide which relation to consider for $|a-d|=40$?
Please help !!!
Thanks in advance !!!
 A: Let the first three terms be $x$, and $x+d$, and $x+2d$. Then the fourth term is $(x+2d)^2/(x+d)$. If we first assume $d$ is positive, then we have
$${(x+2d)^2\over x+d}-x=40$$
which reduces to
$$x={4d(d-10)\over40-3d}$$
Now the only positive integer values of $d$ that give positive integer values of $x$ are $d=12$ and $13$, which give $x=24$ and $156$, respectively. Of these, only $x=24$ is a two-digit number. So if $d$ is positive, then we see that the four numbers must be $24$, $36$, $48$, and $48^2/36=64$, the sum of which is
$$24+36+48+64=172$$
On the other hand, if we assume that $d$ is negative, then we have
$$x-{(x+2d)^2\over x+d}=40$$
which reduces to
$$x=-{4d(d+10)\over40+3d}$$
or, writing $D=40+3d$, so that $d=(D-40)/3$,
$$x={(40-D)(D-10)\over9D}$$
This expression gives an integer value of $x$ if and only if $D$ is a divisor of $400$ congruent to $1$ mod $3$.  Since $400=2^4\cdot5^2$, this limits $D$ to $-200$, $-80$, $-50$, $-20$, $-8$, $-5$, $-2$, $1$, $4$, $10$, $16$, $25$, $40$, $100$, and $400$. From $D=40+3d\lt40$ (since $d$ is assumed to be negative), we can drop the last three possibilities, and from $x\gt0$ we can drop the possibilities $D=1$, $4$, and $10$. From $0\lt x+2d\lt100+2d$ we can drop $D=-200$, $-80$, and $-50$. This leaves six values to check: $D=-20$, $-8$, $-5$, $-2$, $16$, and $25$, which give $x=10$, $12$, $15$, $28$, $1$, and $1$ (again), respectively. But none of these is consistent with the requirement that $x\gt40$. So there are no solutions with $d$ negative.
Remark: The argument here ruling out a descending sequence (i.e., the case with $d$ negative) feels a bit clumsy, but I don't see any easy way to streamline it. Any comments (or alternate answer) improving it would be most welcome.
