Continue a Number Sequence
Detect patterns in number sequences and predict the next terms. Supports arithmetic, geometric, polynomial, Fibonacci, and power sequences.
About
Identifying the generating rule behind a finite sequence of numbers is a core problem in discrete mathematics and psychometric testing. Errors in pattern recognition propagate: a misidentified common difference d yields exponentially diverging predictions after just 3 - 4 extrapolated terms. This tool applies a hierarchy of detection algorithms - finite difference analysis up to order 6, ratio analysis for geometric and exponential forms, linear recurrence scanning for Fibonacci-type rules, and Newton's forward difference formula for polynomial reconstruction. It returns the simplest rule that fits your data, following Occam's razor.
The tool assumes noise-free input. If your data contains measurement error, the detected pattern may be a polynomial artifact rather than the true generating function. For sequences shorter than 3 terms, multiple valid continuations always exist. The tool selects the lowest-order polynomial consistent with the data. Provide at least 4 - 5 terms for reliable detection of quadratic or higher-order patterns.
Formulas
The primary method is finite difference analysis. Given a sequence a1, a2, โฆ, an, the first-order differences are:
If ฮai is constant, the sequence is arithmetic. Otherwise, compute higher-order differences ฮk recursively. If ฮk becomes constant at order k, the sequence is generated by a polynomial of degree k. Newton's forward difference formula reconstructs the next term:
For geometric sequences, the ratio test is applied:
If r is constant for all consecutive pairs, the next term is an โ r. For Fibonacci-type detection, we verify the recurrence an = anโ1 + anโ2 across all valid indices.
Where: ai = the i-th term of the sequence, ฮk = the k-th order finite difference, r = common ratio, d = common difference, n = term index.
Reference Data
| Sequence Type | General Form | Example | Min Terms Needed | Detection Method |
|---|---|---|---|---|
| Constant | an = c | 5, 5, 5, 5 | 2 | 0th-order difference |
| Arithmetic | an = a1 + (n โ 1)d | 2, 5, 8, 11 | 3 | 1st-order constant difference |
| Geometric | an = a1 โ rnโ1 | 3, 6, 12, 24 | 3 | Constant ratio |
| Quadratic | an = an2 + bn + c | 1, 4, 9, 16 | 4 | 2nd-order constant difference |
| Cubic | an = an3 + โฆ | 1, 8, 27, 64 | 5 | 3rd-order constant difference |
| Fibonacci-type | an = anโ1 + anโ2 | 1, 1, 2, 3, 5 | 5 | Recurrence relation scan |
| Power of n | an = nk | 1, 32, 243, 1024 | 4 | Logarithmic ratio analysis |
| Exponential | an = kn | 2, 4, 8, 16 | 3 | Constant ratio (special geometric) |
| Triangular Numbers | Tn = n(n + 1)2 | 1, 3, 6, 10, 15 | 4 | 2nd-order difference = 1 |
| Alternating | an = (โ1)n โ f(n) | 1, โ2, 3, โ4 | 4 | Sign factor extraction |
| Factorial | an = n! | 1, 2, 6, 24, 120 | 5 | Ratio yields 2, 3, 4, 5โฆ |
| Primes | pn | 2, 3, 5, 7, 11 | 5 | Primality test on terms |