Automata in number theory