Let a1 and a2 be first terms and d1 and d2 be common differences of two different arithmetic progressions (A.P.).
We need to find the first term, which is common to both AP’s. If it is not possible that such a term exists, print “-1”.
e.g for a1=2, d1=3 and a2=3, d2=4.
The first common term will be 11.
Solving normally, I got n1d1 - n2d2 = (a2-d2) - (a1-d1) (=c say)
How can we solve this further?