简体   繁体   中英

Next number in the sequence || General approach

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.

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.

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}]

在此处输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM