Gould's Sequence Calculator
Sequences
- Gould's sequence counts the odd entries in each row of Pascal's triangle: a(n) is the number of odd binomial coefficients C(n, k).
- Lucas's theorem reduces that count to a power of two: a(n) = 2 raised to the popcount of n, and 13 has 3 ones in binary.
- So a(13) = 2^3 = 8.
- Plotted row by row, the odd entries draw the Sierpinski triangle - the same fractal behind the sequence's self-similar doubling pattern.
How many entries in row n of Pascal's triangle are odd? The answers form Gould's sequence: row 0 has 1 odd entry, row 1 has 2, row 2 has 2, row 3 has 4, and the counts run 1, 2, 2, 4, 2, 4, 4, 8, ... - every term a power of two. That is not a coincidence but a theorem: a(n) = 2 raised to the popcount of n, the number of 1 bits in n's binary form.
So a(13) needs no triangle at all. 13 in binary is 1101, with three ones, and 2^3 = 8 odd entries. At the extreme, a(1023) = 1024: 1023 is ten ones in binary, and the whole 1024-entry row is odd.
This calculator gives a(n) from the popcount, or lists the first terms so the doubling, self-similar pattern - the shadow of the Sierpinski triangle - is visible.
Worked examples
Gould's sequence at n = 13
(0 - test a single number · 13)
| Gould's sequence value a(13) | 8 |
| number of 1 bits in n (its popcount) | 3 |
| odd entries in row n of Pascal's triangle | 8 |
| next term a(n + 1) | 8 |
Gould's sequence at n = 1023
(0 - test a single number · 1023)
| Gould's sequence value a(1,023) | 1,024 |
| number of 1 bits in n (its popcount) | 10 |
| odd entries in row n of Pascal's triangle | 1,024 |
| next term a(n + 1) | 2 |
First 16 terms
(1 - list up to a limit · 16)
| first 16 terms of Gould's sequence | 1, 2, 2, 4, 2, 4, 4, 8, 2, 4, 4, 8, 4, 8, 8, 16 |
| largest term shown | 16 |
| how many terms equal 1 | 1 |
| last term shown, a(n - 1) | 16 |
What Gould's sequence counts
Pascal's triangle is built from binomial coefficients, and each row mixes even and odd entries in an intricate pattern. Gould's sequence simply counts the odd ones, row by row. Row 3 (1, 3, 3, 1) is all odd: count 4. Row 4 (1, 4, 6, 4, 1) has only the two 1s: count 2. Row 5 (1, 5, 10, 10, 5, 1) has four odd entries. The counts are the sequence.
The striking fact is the regularity hiding in those counts: they are always powers of two, and they depend only on the binary form of n. Henry W. Gould studied the sequence in the 20th century, and it now carries his name - it is OEIS A001316. The calculator's value mode shows the three linked quantities: the popcount of n, the power of two it produces, and the same number interpreted as the odd-entry count.
- a(n) = number of odd C(n, k) for k = 0..n
- Named for Henry W. Gould
- Every term is a power of two
- a(0) = 1: the single entry 1 is odd
The popcount shortcut
Lucas's theorem, applied in base 2, says C(n, k) is odd exactly when every 1 bit of k is also a 1 bit of n - k is a bitwise submask of n. Counting the odd entries in row n is therefore counting the submasks of n, and a number with p ones in binary has exactly 2^p submasks. Hence a(n) = 2^popcount(n), with no triangle and no binomial arithmetic.
The examples make it tangible. 13 is 1101 in binary, popcount 3, so a(13) = 8. 1023 is 1111111111, popcount 10, so a(1023) = 2^10 = 1024 - and indeed every one of the 1024 entries in that row is odd, because every k from 0 to 1023 is a submask of 1023. The calculator's list mode lets you watch the popcount mechanism generate the sequence term by term.
- Lucas: C(n, k) is odd iff k's 1 bits are contained in n's
- Each 1 bit of n doubles the count
- a(13) = 2^3 = 8 since 13 = 1101 in binary
- a(1023) = 2^10 = 1024: every k qualifies
The first terms and the pattern
From a(0), the sequence runs 1, 2, 2, 4, 2, 4, 4, 8, 2, 4, 4, 8, 4, 8, 8, 16. The structure is exact self-similarity: the block of terms from a(2^k) to a(2^(k + 1) - 1) is precisely double the block before it, because adding a new leading 1 bit to n raises the popcount of every number in the block by one. The list mode shows the largest term in the window and how many terms equal 1 - always just the single a(0), since every n >= 1 has at least one 1 bit.
Two landmarks orient the pattern: at exact powers of two, a(2^k) = 2 - a row like row 4 with only its endpoints odd - while just before them, a(2^k - 1) = 2^k, the maximum possible, a completely odd row. The sequence oscillates between these extremes with total regularity, a sawtooth built from pure powers of two.
- First 16 terms: 1, 2, 2, 4, 2, 4, 4, 8, 2, 4, 4, 8, 4, 8, 8, 16
- Block structure: each block of 2^k terms doubles the previous
- a(2^k) = 2 and a(2^k - 1) = 2^k
- The value 1 occurs only at n = 0
Why every term is a power of two
Plot Pascal's triangle keeping only the parity of each entry - a dot for odd, a blank for even - and the Sierpinski triangle materialises: nested triangular holes at every scale. Gould's sequence counts the dots row by row, and the fractal's self-similarity is exactly the sequence's block-doubling. The power-of-two law is the numerical shadow of that geometry: a fractal built by doubling has counts that are powers of two.
The same pattern appears as Rule 90, the elementary cellular automaton whose spacetime diagram is the Sierpinski triangle, and whose row counts of live cells are again Gould's sequence. It is a small example of a big phenomenon - a counting sequence that looks arbitrary until the right representation (binary, here) reveals it as a simple mechanism wearing a disguise.
- Odd entries plotted draw the Sierpinski triangle
- The doubling blocks are the triangle's self-similarity
- Same Lucas mechanism as the ruler function's world of 2-adic patterns
- Connects binomial parity to cellular automaton Rule 90
Computing with the popcount law
The popcount formula turns a potentially enormous computation into a trivial one. Row 1000 of Pascal's triangle has 1001 entries, many with hundreds of digits; counting its odd entries by hand is hopeless, but a(1000) needs only the binary form of 1000 - 1111101000, six ones - so a(1000) = 2^6 = 64. Sixty-four odd entries among 1001: as rows grow, the odd entries become proportionally rarer, because popcounts concentrate near half the bit length while row lengths double. The density of odd entries in row n is 2^popcount(n) / (n + 1), which tends to zero along most subsequences even though every row has some.
Hardware makes the computation literal: modern processors have a dedicated popcount instruction, so a(n) is one instruction plus a shift. Programmers meet the same quantity in chess engines (piece counts on a bitboard), cryptography (Hamming weights), and error-correcting codes. Gould's sequence is the number-theoretic face of that instruction - the count of odd binomial coefficients was, in hindsight, always a popcount waiting for its theorem.
The calculator's list mode shows the first n terms with the largest term and the count of 1s. The 1s are instructive: a(n) = 1 only at n = 0, because popcount(n) = 0 only there. Every other row of Pascal's triangle has at least the two endpoint 1s odd - a(n) >= 2 for all n >= 1 - which the sequence confirms at a glance.
- a(1000) = 64 from popcount(1000) = 6
- Odd entries get proportionally rarer as rows grow
- One hardware instruction: popcount
- a(n) = 1 only at n = 0; a(n) >= 2 afterwards
Worked checks and pitfalls
Verify the popcount law against a row you can write out. Row 5 of Pascal's triangle is 1, 5, 10, 10, 5, 1: the odd entries are 1, 5, 5, 1 - four of them. And 5 in binary is 101, popcount 2, 2^2 = 4. Row 6 is 1, 6, 15, 20, 15, 6, 1: odd entries 1, 15, 15, 1 - again four. 6 is 110 in binary, popcount 2, 2^2 = 4. Row 7 is famously all odd - 1, 7, 21, 35, 35, 21, 7, 1 - eight entries, and 7 is 111, popcount 3, 2^3 = 8. Three rows, three confirmations, no triangle required beyond the demonstration.
The pitfall is indexing: this calculator's a(0) = 1 corresponds to row 0, the single 1 at the triangle's apex. Sources that start counting rows at 1 shift every value by one position. When comparing against a reference, align on a landmark - a(7) = 8 for the all-odd row of eight - rather than on position alone.
- Row 5: four odd entries, popcount(5) = 2
- Row 7 is all odd: a(7) = 8
- a(0) = 1 is the apex row
- Align references on landmarks, not positions
A note on computation limits
Value mode on this calculator is effectively unlimited for hand use - the popcount law costs nothing at any n a person would type. List mode is the bounded one, since it materialises terms. The deeper point is the contrast with the naive method: counting odd entries by constructing Pascal's triangle up to row n costs O(n^2) big-integer additions and collapses long before n = 1000, while Lucas's theorem answers in O(log n). Gould's sequence is a clean classroom example of a theorem replacing a computation - the sequence did not change, but what it costs to know it fell by orders of magnitude.
- Popcount law: O(log n) per term
- Naive triangle: O(n^2) and collapses early
- A theorem replacing a computation
FAQs
What is Gould's sequence?
The count of odd entries in row n of Pascal's triangle: a(13) = 8, for example.
How is a(n) computed without Pascal's triangle?
By Lucas's theorem, a(n) = 2 raised to the popcount of n - the number of 1 bits in n. No triangle required.
What is a(1023)?
1024, because 1023 in binary is ten ones, and 2^10 = 1024 - the entire row of Pascal's triangle is odd.
What are the first terms?
From a(0): 1, 2, 2, 4, 2, 4, 4, 8, 2, 4, 4, 8, 4, 8, 8, 16.
Why is every term a power of two?
Lucas's theorem in base 2: each 1 bit of n independently doubles the count of odd binomial coefficients, and there is one factor of 2 per bit.
What fractal do the odd entries draw?
The Sierpinski triangle - the odd entries of Pascal's triangle, plotted, draw that fractal.