Next number in the sequence || General approach

320 Views Asked by At

how can I find the next number in this sequence ,

1, 4, 7, 8, 13, 12, 9 , ?

How to check , given any sequence of numbers , feasible or not. Any general theory or approach is very much welcomed .

2

There are 2 best solutions below

1
Bill On

One method is to go to the Online Encyclopedia of Integer Sequences and enter your list of at least six or eight numbers into the box and see if that happens to be a known sequence. For your example this doesn't find a known sequence.

If that doesn't work then you can try Mathematica's FindFormula

p=FindFormula[{1, 4, 7, 8, 13, 12, 9}];

and then

p[1] returns 1, p[2] returns 4, p[3] returns 7... and p[8] returns 106, etc.

You can read the documentation on FindFormula and you can look at the formula p by using InputForm[p] where #1 represents a variable in the function p.

In general I think this is rarely going to produce the result that you are looking for.

0
Chris Degnen On
seq = FindSequenceFunction[{1, 4, 7, 8, 13, 12, 9}, n]

(48 - 74 n - 14 n^2 + 11 n^3 - n^4)/(3 (-13 + 3 n))

Checking the 7th number

n = 7;
seq

9

The next number is a fraction, apparently

n = 8;
seq

32/11

Show[Plot[seq, {n, 1, 10}],
 ListPlot[Table[seq, {n, 1, 10}]],
 PlotRange -> {{0, 10}, {-20, 30}}, AxesOrigin -> {0, 0}]

enter image description here