1. Ok, on the first one you need to recognize something special. Consider the partial summations of the sequence.

After 1 term we have -9 (no summation here).

After 2 terms we have -9+18 = 9.

After 3 terms we have 9+(-27) = -18.

After 4 terms we have -18+36 = 18.

After 5 terms we have 18+(-45) = -27.

After 6 terms we have -27+54 = 27.

I'm sure that the pattern is becoming aparent by now! After 2 terms, the sum equals 9 and so when =20, you have 40 terms, which sum to 9.20 = 180 and you are done!

If you are familiar with summation notation, here is a way to get this. Your sequence is of terms where is the initial number and in your case it is 9. If S_t is the sum of the first t terms, then after terms, we have.

Now, if we want , we can get it by taking the following approach:

So you can see that neighboring sums will give the same terms except for the sign. So you set , giving you n = 20 and 2n = 40 terms.

2. This one is not simple. I have found which B gives the longest sequence via brute force search through all possibilities. What are those possibilities? t1 = 150. t2 = B and if it is a negative number, we get t3 = t1 +|B|, which is larger than B, so t4 < 0, so disregard negative values. Similarly, if B >150, we get t3<0 and the sequence terminates quite short still. So the range of values we have to check is from B = 0 to B = 150, which is easy enough if you know how to program. I'll just tell you that the longest sequence is of length 8.

However, it is most interesting to find a "smart" solution. Here is a heuristic approach that may help you. You want the consecutive terms in the sequence to be decreasing, but decreasing as slowly as possible, since you want to create the largest sequence. Hence it makes sense to choose B large, so make that difference between terms as small as possible. However, once you obtain t3 = t1 - B, it is quite small, so that does not work. This just shows that you need to somehow balance the input B so that the difference between t1 and B is small but also the difference between B and t3 = t1 -B is small also.