Find if a number lies in this pattern

104 Views Asked by At

I have a sequence of numbers below...

$1, 2, 4, 7, 11, 16 ...$

You get this list by starting at $1$ then add $1, 2, 3, 4, 5 ...$

Given a number $n$, how can I determine if it will show up in this pattern of numbers?

2

There are 2 best solutions below

2
On BEST ANSWER

The $k$th term in your sequence is $1+\frac{k(k-1)}{2}$. [See triangular numbers.] Given your number $n$, you just need to check if it is of this form or not.

14
On

Put another way, take your number, multiply by $8,$ then subtract $7.$ If the result is a perfect square, the number is in the sequence, otherwise no.