context.divkbaseb(k, b)

Generates an automaton that recognises the writing in base $b$ of the numbers divisible by the integer $k$.

Preconditions:

  • $2 \le b$
  • the labelset has at least $b$ generators

Postconditions:

  • the automaton has $k$ states

Examples


In [1]:
import vcsn
c = vcsn.context('lal_char(0-9), b')
c.divkbaseb(3, 2)


:0: FutureWarning: IPython widgets are experimental and may change in the future.
Out[1]:
%3 I0 0 0 I0->0 F0 0->F0 0->0 0 1 1 0->1 1 1->0 1 2 2 1->2 0 2->1 0 2->2 1

In [2]:
c.divkbaseb(2, 4)


Out[2]:
%3 I0 0 0 I0->0 F0 0->F0 0->0 0, 2 1 1 0->1 1, 3 1->0 0, 2 1->1 1, 3

If $k$ and $b$ are coprime, then the result is known to be minimal.


In [3]:
div4base4 = c.divkbaseb(4, 4)
div4base4


Out[3]:
%3 I0 0 0 I0->0 F0 0->F0 0->0 0 1 1 0->1 1 2 2 0->2 2 3 3 0->3 3 1->0 0 1->1 1 1->2 2 1->3 3 2->0 0 2->1 1 2->2 2 2->3 3 3->0 0 3->1 1 3->2 2 3->3 3

In [4]:
div4base4.minimize()


Out[4]:
%3 I0 0 0 I0->0 F0 0->F0 0->0 0 1 1, 2, 3 0->1 [1-3] 1->0 0 1->1 [1-3]