The OEIS mourns the passing of Jim Simons and is grateful to the Simons Foundation for its support of research in many branches of science, including the OEIS.
login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A257291 Number of states in minimal DFA accepting base-2 representation of first n prime numbers. 2
4, 4, 5, 5, 6, 8, 9, 9, 10, 11, 11, 12, 13, 13, 14, 16, 17, 17, 19, 20, 21, 21, 21, 22, 23, 23, 24, 24, 24, 25, 26, 27, 28, 28, 29, 29, 31, 32, 33, 35, 36, 36, 37, 38, 38, 38, 39, 40, 41, 40, 41, 41, 42, 43, 44, 44, 44, 45, 46, 46, 47, 47, 48, 48, 49, 49, 49, 51, 52, 52, 54, 55, 55, 56, 56, 57, 58, 58 (list; graph; refs; listen; history; text; internal format)
OFFSET
1,1
COMMENTS
By "DFA" we mean deterministic finite automaton, which must be "complete" (that is, a transition must exist for every state). So the minimal DFA for n = 1 corresponds to a DFA that accepts the string "10" and no other. Four states are required since a "dead state" is also needed.
LINKS
EXAMPLE
From Kevin Ryde, Jun 02 2020: (Start)
For n=3, the minimum DFA comprises a(3) = 5 states:
+------------------------+
start 1 | v
+-----------+ 1 +--------+ 0 +=====+ 1 +=====+
| 10,11,101 | ---> | 0,1,01 | ---> | e,1 | ---> | e |
+-----------+ +--------+ +=====+ +=====+
| 0 | 0 | 0,1
| | v
| | +------+
+-------------------------------+------> | dead |
+------+
^ | 0,1
+-+
Each state is a set of bit strings wanted. The start state is primes 2,3,5 in binary. Each "1" transition takes strings starting 1 and removes that 1. Each 0 transition similarly. "e" is the empty string. Each state containing "e" is accepting because it's the end of one of the original primes. "Dead" is the set of no strings and is a non-accepting sink. Input strings too long or not a prefix of one of the desired primes end up at dead.
(End)
PROG
(PARI) a(n) = {
my(m=Map(), q=List([apply(p->Vecsmall(binary(p)), primes(n))]));
while(#q, my(s=q[#q]); listpop(q);
if(!mapisdefined(m, s), mapput(m, s, 1);
for(i=0, 1, listput(q, apply(v->v[^1],
select(v->#v&&v[1]==i, s))))));
#m; } \\ Kevin Ryde, Jun 02 2020
(Python)
from sympy import prime, primerange
def a(n):
m = dict()
q = [tuple(bin(p)[2:] for p in primerange(1, prime(n)+1))]
while len(q) > 0:
s = q.pop()
if s not in m:
m[s] = 1
for i in "01":
q.append(tuple(v[1:] for v in s if len(v) and v[0]==i))
return len(m)
print([a(n) for n in range(1, 80)]) # Michael S. Branicky, Jul 04 2022 after Kevin Ryde
CROSSREFS
Cf. A257371.
Sequence in context: A003869 A065864 A120205 * A152465 A357414 A082968
KEYWORD
nonn
AUTHOR
Jeffrey Shallit, Apr 21 2015
EXTENSIONS
a(26)-a(78) from Kevin Ryde, Jun 02 2020
STATUS
approved

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified May 15 17:15 EDT 2024. Contains 372548 sequences. (Running on oeis4.)