# 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: # concatenate 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) ; _______________________________________________