Free Online Utility • MATH Studio • Exact BigInt Engine

Generate Stanley Number Sequence

Generate Stanley numbers (OEIS A005836: 0, 1, 3, 4, 9, 10, 12, 13, 27...)—the greedy 3-term arithmetic-progression-free sequence consisting of integers with no digit 2 in base 3.

Formula & Quick Reference Live Engine
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, ...
k = 0..30, 1, 3, 4
k = 4..79, 10, 12, 13
k = 827
EXACT INTEGER SEQUENCE · OEIS A005836
Generate Stanley Number Sequence

        
100% client-side exact mathematics Instant

Session Calculation Log

No entries recorded in this session yet.

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

  1. 1Pick a quick preset or enter any term count up to 5,000.
  2. 2Choose comma, space, or newline separation and optionally toggle 1-based term indexing.
  3. 3Copy plain text, export structured JSON, or download a .txt file with one click.

Reference Examples & Worked Benchmarks

Index / MilestoneExact TermNotes
k = 0..30, 1, 3, 4Base-3: 0, 1, 10, 11
k = 4..79, 10, 12, 13Base-3: 100, 101, 110, 111
k = 827Base-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.

Frequently Asked Questions

Why are 2, 5, 6, 7, 8 missing from Stanley numbers?
Adding 2 would form the arithmetic progression (0, 1, 2); adding 5 forms (1, 3, 5); adding 6 forms (0, 3, 6); adding 7 forms (1, 4, 7); and adding 8 forms (0, 4, 8).
How are Stanley numbers connected to the Cantor set?
Rescaling the base-3 digits {0, 1} to {0, 2} produces the exact ternary endpoints of the classic middle-thirds Cantor set.