# Get sequence given the first few elements of the sequence

Is there any tool to get math sequence given the first few elements of the sequence.

I am trying to solve a few problems from projecteuler. I am looking for a math tool that can generate me a sequence formula.

Example given inputs like

5, 7, 9, 11, 13.....


The tool should detect its an arithmetic progression and give me following

a(n) = 5 + (n-1) 2


A more complicated example would be from the link I provided above

1, 3, 5, 7, 9, 13, 17, 21, 25 .....

-
Wouldn't it be better to figure out the pattern yourself, then use the pattern to come up with an equation? Exactly what kinds of sequences is it supposed to solve? Arithmetic? Geometric? Arithmetic-geometric? –  Mike Feb 3 '13 at 8:18

Is the on-line encyclopedia of integer sequences good enough?

-
Thanks for this... –  ZEN.Kamath Feb 3 '13 at 8:30

A general strategy for determining patterns in sequences like the ones you show here is to analyze differences as follows. Consider your more complicated sequence:

$$1, 3, 5, 7, 9, 13, 17, 21, 25, \ldots$$

The first difference here is

$$2, 2, 2, 2, 4, 4, 4, 4, \ldots$$

So we see a constant difference, then a jump to another constant difference. You can see this even more clearly by taking the difference of the difference:

$$0, 0, 0, 2, 0, 0, 0, \ldots$$

A better example, though is a smooth one, like the squares of the integers:

$$1, 4, 9, 16, 25, 36, 49, 64 \ldots$$

The first difference is

$$3, 5, 7, 9, 11, 13, 15, \ldots$$

which you can see is a linear sequence. The second difference

$$2, 2, 2, 2, 2, 2, \ldots$$

is a constant sequence, which is characteristic of a sequence that increases quadratically. You can play around with all sorts of such sequences and see how their differences behave.

Taking further differences will not lead to a set of zeroes because of the isolated jump. So we can say that we have a discontinuity in the sequence away from which we have two linear subsequences.

-