Complete Technical Guide to Generate Stanley Number Sequence
Stanley numbers (OEIS A005836) are generated by a simple greedy rule: start with 0 and 1, and repeatedly add the smallest larger integer that does not create any 3-term arithmetic progression (a, b, c with a + c = 2b) with earlier terms.
Equivalently, the k-th Stanley number is obtained by writing k in binary and reading those exact bits in base 3—linking additive combinatorics directly to the discrete Cantor set.
Binary-to-Ternary Closed Form (No 3-Term AP)
S(k) = Σ_{i} b_i · 3^i where k = Σ_{i} b_i · 2^i (b_i ∈ {0, 1})
First terms: 0, 1, 3, 4, 9, 10, 12, 13, 27, 28, 30, 31, 36, 37, 39, 40, ...
Odlyzko and Stanley proved that starting with {0, 1} and greedily appending the smallest integer forming no 3-term arithmetic progression produces precisely the integers containing only 0s and 1s in base 3.
How to Use Generate Stanley Number Sequence
- 1Pick a quick preset or enter any term count up to 5,000.
- 2Choose comma, space, or newline separation and optionally toggle 1-based term indexing.
- 3Copy plain text, export structured JSON, or download a .txt file with one click.
Reference Examples & Worked Benchmarks
| Index / Milestone | Exact Term | Notes |
|---|---|---|
| k = 0..3 | 0, 1, 3, 4 | Base-3: 0, 1, 10, 11 |
| k = 4..7 | 9, 10, 12, 13 | Base-3: 100, 101, 110, 111 |
| k = 8 | 27 | Base-3: 1000 (skips 2,5..8,14..26) |
Practical Applications & Engineering Workflows
Combinatorics & Number Theory
Generate verified terms of OEIS A005836 instantaneously for proofs, OEIS lookups, and test fixtures.
Algorithm & Curriculum Verification
Cross-check exact BigInt outputs without floating-point overflow past 2^53.
Accuracy, Edge Cases & Best Practices
- All calculations run locally in your browser using exact BigInt / sieve arithmetic matching OEIS A005836.
All calculations execute locally inside your browser using JavaScript with zero server round-trips, guaranteeing instant responsiveness and complete data privacy.