I submitted the sequence A267263 to the Online Encyclopedia of Integer Sequences (OEIS).
It’s defined as the ‘number of nonzero digits in representation of n in primorial base’.
But… what does that mean? Let’s break it down:
- Primorial
-
The product of the first prime numbers: .
-
Defined in the OEIS as sequence A002110.
- Primorial number system
-
A mixed radix representation using the primes as the place values, instead of the usual base-10.
-
For example, thirteen is: .
So, this is basically another way of writing numbers down, or representing them and assigning them to ‘strings’ of digits. The way we usually do is with base-10, also called decimal. Since successive place values in base-10 is multiplied by , thus the value of is in decimal.
However, in the primorial number system, the place values are the products of the first prime numbers. So, the value of is in primorial.
In effect, this sequence describes how many ‘imperfect matches’ a number has when reducing modulo subsequent primes. It is analogous to the Hamming weight of a binary number, but in a different base.

No, Really, What Does It Mean?
Well, it’s sort of a curiosity. It came up when I was studying algorithms for searching for prime generating polynomials. In the same way that the computational complexity of modular exponentiation is determined by the Hamming weight of the exponent, the A267263 sequence appears in the computational complexity of algorithms based on recursive wheel factorization.
I realize that this just introduced more questions than it answered. I plan on writing more about these topics, but for now, I just wanted to share this interesting sequence. For now, I’ll leave you with a table of the first few values of the sequence, and a way to generate these values in Python.
Calculating the Sequence
Here’s a table of the first few values of the sequence, along with their primorial string representation:
0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | 1 | 1 | 2 | 1 | 2 | 1 | 2 | 2 | 3 | 2 | 3 | 1 | 2 | 2 | 3 | |
Primorial String | 0 | 1 | 10 | 11 | 20 | 21 | 100 | 101 | 110 | 111 | 120 | 121 | 200 | 201 | 210 | 211 |
Hence, the sequence A267263 is defined as the number of bolded digits in the primorial string representation of .
To generate the information in this blog, I use the following Python code:
11 collapsed lines
# A267263.py - exploration of an integer sequence: https://oeis.org/A267263# NOTE: read a full post at: https://cade.io/a267263
# we use a lazy prime generator from SymPyfrom sympy import sieve
# pandas is just used for conversion to a markdown tableimport pandas
# digits used for string conversionDIGITS = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'
def A267263(n: int) -> int: ''' Number of nonzero digits in representation of n in primorial base. ''' return sum(1 for n in primorial_residues(n) if n != 0)
def primorial_residues(num: int) -> list: ''' Calculates successive residues in the primorial radix system. ''' res = []
# at each step, maintain the current 'digit' and what's left div, mod = num, 0 for prime in sieve:
# quit once we have enough residues to represent the number if div == 0: break
# otherwise, continue to extract the next residue div, mod = divmod(div, prime) res.append(mod)
# and so, we will have place values for: [2#, 3#, 5#, ...] return res
8 collapsed lines
def primorial_string(num: int) -> str: ''' Converts a number to its primorial representation ''' # NOTE: this won't work for very large numbers that exceed (37#) return ''.join(DIGITS[n] for n in primorial_residues(num)[::-1]) or '0'
def bold_nonzeros(s: str) -> str: ''' Bolds all non-zero digits in a string ''' return '0'.join(f'**{ss}**' if ss else '' for ss in s.split('0'))
# generate a table of values and useful information to displayrows = [(n, A267263(n), bold_nonzeros(primorial_string(n))) for n in range(16)]df = pandas.DataFrame(rows, columns=['$n$', '$A267263(n)$', 'Primorial String'])
5 collapsed lines
# transpose the dataframe, to change orientationdf = df.transpose()df.columns = df.iloc[0]df = df[1:]df.index.name = '$n$'
# print the transposed table as markdownprint(df.to_markdown(index=True, stralign='right'))
This requires a few dependencies, which you can install with:
pip install sympy pandas tabulate