← All projects / The Formulas

Every pattern, in one line

Any pattern of bits that repeats can be written as a short formula. This page has the formula for every family on the site, and the few that don't have one. Each formula is checked against its pattern as the page loads.

Why a repeating pattern always has a formula

The trick, with ordinary digits

999 is 1,000 minus 1. So 111 is 999 ÷ 9, which is (103 − 1) ÷ 9. Any run of ones works the same way, and any repeating block is just a run of ones times the block: 474747 is 47 × 10101.

The same trick in binary

The 0101 numbers are a 1 in every second place. That's a run of ones counted in fours, so it's (4k − 1) ÷ 3. Three on, three off repeats every six bits, so its formulas use 64, which is 26.

What a formula is good for

It skips the building. Row 100 of the 67s is 299 + 3, with no need to work through the 99 rows before it. And it's what makes proofs possible: every "proved" on this site came from one of these lines.

What it can't do

It gives you the numbers. It doesn't tell you which of them are prime. For that, each one still has to be tested.

The families

FamilyFormulaWhere the letter runsFirst numbers it givesCheck

Jump to any row

Up to 20,000. Long answers show their first and last digits and how many digits there are.

The same families, written straight down in base 8

A base-8 digit is worth exactly three bits. So any power of two is a 1, a 2 or a 4 followed by zeros: split the power into threes with something left over, n = 3q + r, and 2n = 2r × 8q. Swap that into each formula and it turns into a recipe for the digits themselves.

FamilyIn powers of 8How to write it downFirst ones, in base 8Check

The leading digit goes round in threes

Row after row, the front digit of the 1null1s and 67s steps 1, 2, 4, and then a zero is added and it starts again. The 97s do the same with 3, 6 and 14, because their front is three times a power of two.

One third is 0.2525... and two thirds is 0.5252...

That's why 0101 is all 2s and 5s. In binary a third is 0.0101 for ever. Group those bits in threes and you get 010, 101, 010, 101, which reads 2, 5, 2, 5.

A ninth is 0.0707...

Three off, three on is 000 then 111, which reads 0 then 7. So the 000111s are a 1, 3 or 7 followed by 07 over and over.

Where it doesn't work

The 666s have no tidy recipe here. Their pattern is ten bits long and a base-8 digit is three, so the two only line up every thirty bits. The Fibonacci and prime families never repeat at all, so they have no recipe in any base.

The mixes and the sixes

The families made by inverting one family by another, from the mixing page, and the strings of sixes from the 666 page.

PatternFormulaWhere the letter runsFirst numbers it givesCheck

The ones with no formula

A short formula needs a pattern that repeats. These two never do, so the best anyone can write is "add up one piece for every Fibonacci number" or "for every prime". That isn't a shortcut. It's the building, written down.

FamilyThe best there isWhere the letter runsFirst numbers it givesCheck

Fibonacci could be shortened a little

There is a formula for the Fibonacci numbers themselves, so you can say where each 1 goes without counting. But the family's numbers still have to be added up one piece at a time.

The primes can't

Nobody has a usable formula for where the primes are. That's the same wall every search on this site ran into, seen from the other side.

The other formulas on this site

WhatFormulaStatusWhere
Last digitn modulo 10exactModulo
Digital root1 + (n − 1) modulo 9exactHoly 1010
Hour on the 24-hour clockn modulo 24exactModulo
Stay-put digit of a rule "times m, plus c"the digit d where m × d + c ends in dexactAll the Families
A family and its mirrorfamily + mirror = 2n − 1exactThe Whole Map
How deep "a power of two plus c" stays unevenat most the number of bits in cprovedAll the Families
A 0101 number, tripled and plus 13 × (4k − 1) ÷ 3 + 1 = 4kexactHoly 1010
A 0101 number, split in two(2k − 1) × (2k + 1) ÷ 3provedPrimes
What the 666s close in on666 ÷ 1,023 = 222 ÷ 341exact666
666 against the strongest signal682 − 666 = 16exactMixing
Primes up to a number Nroughly N ÷ (2.3 × its digit count)rule of thumbPrimes
Wait for the next prime rowroughly the row ÷ 3.6 for the 67s and 97smeasuredPrimes
All the modulo families added up1 + 1⁄3 + 1⁄7 + 1⁄15 + ... = 1.6067exactModulo