# Find the Pattern in 3+6+12+20+30 +n

1. Nov 13, 2014

### ChiralWaltz

1. The problem statement, all variables and given/known data
Write a loop in C for to sum the following sequence 3+6+12+20+30+...nth.

2. Relevant equations
n/a

3. The attempt at a solution
I have tried to factor but there are no common factors between 3 and 20 other than 1.

2*5=10------->10+20=30
2*4=8--------->8+12=20
2*3=6--------->6+6=12
2*2=4--------->4+3=7:(

I'm stuck. Any ideas?

2. Nov 13, 2014

### Joffan

Recheck the first term. Hopefully it's 2.

Otherwise OEIS is kind-of your friend - you'll maybe get an answer, but it probably won't be an answer you'll like. https://oeis.org/A066140 is not a sequence you can easily generate.

The other (programming) option is to bounce the problem of the nth term into a function - which you leave unspecified.

3. Nov 13, 2014

### ChiralWaltz

Thanks for the link. I have no idea what the reply was telling me.

I'm pretty sure the 3 should be a 2 also.

4. Nov 14, 2014

### BvU

What if someone utters "hey this looks like $\displaystyle 1+\sum_1^N n(n+1)\$ "?

5. Nov 14, 2014

### ChiralWaltz

If someone were to utter that, I would enthusiastically test values.

N=4

1+1(1+1) = 3
1+2(2+1) = 7
1+3(3+1) = 13 :(
1+4(4+1) = 21 :L

Then I would be disappointed and confused as to if I was doing the problem right.

6. Nov 14, 2014

### BvU

Don't understand. I see 3+6+12+20+30+...nth.
I notice 3 = 1+ 1*2, 6 = 2*3, 12 = 3*4, 20 = 4*5, 30 = 5*6
So methinks $$3+6+12+20+30 = \displaystyle 1+\sum_1^N n(n+1)\$$

(not $\sum_1^N 1 + n(n+1)\$ as in post #5)

7. Nov 14, 2014

### Joffan

This is exactly the same as saying the first term of the series should be 2. - except it isn't, so lets just add a constant to that one term. You are also trying to jump to the sum instead of trying to identify the sequence.

I thought of a kludge to get us around the "faulty" start to the sequence:

$s_n = \max(n+(n+1), n*(n+1))$

Last edited: Nov 14, 2014
8. Nov 14, 2014

### BvU

Well, sorry for the confusion. I see your problem. My pattern recognition capabilities aren't up to having 3 as a starting term, so I made it (too?) easy for mself.