# [seqfan] Re: Primes with increasing digits

Richard Mathar mathar at strw.leidenuniv.nl
Wed May 12 13:49:46 CEST 2010

```http://list.seqfan.eu/pipermail/seqfan/2010-May/004635.html

The first 80 terms that I get agree with Hugo's (and I didn't check beyond
that index range).

This adds to the statistics that we always feel uncomfortable
with base-related sequences because their error rate is higher than for
the others. The likely reason is that the authors who submit
them do not use programming, and substitute this with a more free-arts, liberal,
creative spirit of inventing the numbers:

2, 3, 5, 7, 89, 127, 919, 1237, 8923, 8929, 8969, 12347, 89123, 89137, 89189,
89237, 89269, 89293, 89393, 89459, 89491, 89567, 89591, 89597, 89689, 89797,
89891, 89897, 91237, 91249, 123457, 891239, 891349, 891379, 891389, 891391,
891491, 891493, 891593, 891679, 891797, 891893, 891923, 891929, 891967,
892357, 892391, 892457, 892579, 892597, 892919, 893479, 893489, 893567,
893591, 893797, 893897, 893917, 893929, 893939, 893989, 894589, 894689,
894791, 894793, 894893, 894917, 894923, 894947, 895691, 895789, 895913,
895927, 895957, 896897, 896927, 896947, 897947, 898927, 912349

# Maple program for A068827:
# number of digits in n
A055642 := proc(n)
max(1,1+ilog10(n)) ;
end proc:

# intial digit of n
A000030 := proc(n)
if n = 0 then
0;
else
op(-1,convert(n,base,10)) ;
end if;
end proc:

# catenate all members of the list L
catL := proc(L)
local a,i,nds;
a := op(1,L) ;
for i from 2 to nops(L) do
nds := A055642(op(i,L)) ;
a := 10^nds*a+op(i,L) ;
end do;
a;
end proc:

# return allowed digit range for digit following prevdig
A068827aux := proc(prevdig)
local digmin,digmax ;
if prevdig = 9 then
digmin := 1 ;
digmax := 8 ;
else
digmin := prevdig+1 ;
digmax := 9 ;
end if;
return [digmin,digmax] ;
end proc:

# check whether the digits of a, starting with the 2nd, are an allowed sequence
isA068827aux := proc(a)
local dgs,drange,i ;
dgs := convert(a,base,10) ; # list digits right to left
for i from 2 to nops(dgs) do
drange := A068827aux(op(1-i,dgs)) ;
if op(-i,dgs) < op(1,drange) or op(-i,dgs) > op(2,drange) then
return false;
end if;
end do:
return true;
end proc:

# compute A068827(n)
A068827 := proc(n)
option remember;
local a,pdig,drange;
if n = 1 then
2;
else
# last digit of the previous a(n-1)
pdig := procname(n-1) mod 10 ;
drange := A068827aux(pdig) ;

# next a(n) must be prime...
a := nextprime(procname(n-1)) ;
while true do
if A000030(a) >= op(1,drange) and A000030(a) <= op(2,drange) then
if isA068827aux(a) then
return a;
end if;
end if;
a := nextprime(a) ;
end do:
end if;
end proc:
seq(A068827(n),n=1..80) ;

```