first term = a
second term = b
last term = c
so, common difference = (b-a)
now, let last term be the Nth term of the AP
L = a + (n-1) d
=> c = a + (n-1) (b-a)
=> c = a + nb -an -b +a
=> c = 2a -an +nb -b
=> c = 2a -b +nb -an
=> n = (b+c-2a) / (b-a)
now,
Sn = n/2 (first term + last term)
=> Sn = (b+c-2a) (a+c) / 2(b-a)