Question 999052
How many three terms APs are possible whose elements belongs to a
given set of natural numbers {1,2,3,4,5,.....,40} and common 
difference is a positive integer

<pre>
Case 1: For the middle term less than or equal to 20:

If 2 is the middle term, there is 1 possibility for the 1st term, 
{1}
If 3 is the middle term, there are 2 possibilities for the 1st term, 
{1,2}
If 4 is the middle term, there are 3 possibilities for the 1st term, 
{1,2,3} 
...
This pattern continues to:

If 20 is the middle term, there are 19 possibilities for the 1st term, 
{1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19}

However this pattern stops at 20, because if the middle term is 21
the 1st term cannot be 1 because the common difference will be 20,
which would make the 3rd term be 21+20=41 which cannot be the 3rd term.

So for case 1, we need the sum of the first 19 positive integers.

The formula for the sum of the first n positive integers is n(n+1)/2
and so for case 1, this will be (19)(20)/2 = 380/2 = 190
--------------------

So for middle terms greater than 21 we have another pattern.

--------------------
Case 2:
For any 2nd term n, 39 &#8805; n &#8805; 21, 

If 39 is the middle term, there is 1 possibility for the 3rd term, 
{40}
If 38 is the middle term, there are 2 possibilities for the 3rd term, 
{39,40}
If 37 is the middle term, there are 3 possibilities for the 3rd term, 
{1,2,3} 
...
This pattern continues to
If 21 is the middle term, there are 19 possibilities for the 3rd term, 
{22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39}
This pattern, of course, stops at 21, and the rest are case 1.
  
This is also the sum of the first 19 positive integers, which we have
already calculated as 190.

So the answer is twice that or 380.

Edwin</pre>