login
A158457
a(1)=1, a(n+1) is the largest nonprime < sum of digits of n and a(n).
1
1, 1, 1, 1, 4, 8, 12, 9, 16, 15, 6, 6, 8, 10, 4, 9, 15, 12, 10, 10, 1, 1, 4, 8, 12, 9, 16, 15, 15, 16, 9, 12, 6, 10, 6, 12, 10, 10, 10, 12, 6, 10, 6, 12, 10, 9, 18, 18, 20, 14, 9, 14, 10, 8, 16, 16, 16, 18, 21, 16, 12, 9, 16, 15, 15, 16, 18, 21, 16, 21, 9, 16, 15, 15, 16, 18, 21, 16, 21
OFFSET
1,5
LINKS
EXAMPLE
1, 1(<2=1+1), 1(<3=2+1), 1(<4=3+1), 4(<5=4+1), 8(<9=5+4), 12(<14=6+8), 9(<10=7+1+2), etc.
MAPLE
Contribution from R. J. Mathar, May 21 2010: (Start)
A007953 := proc(n) add(d, d=convert(n, base, 10)) ; end proc:
A158457 := proc(n) if n = 1 then 1; else for a from A007953(n-1)+A007953(procname(n-1))-1 by -1 do if not isprime(a) then return a; end if; end do; end if; end proc:
seq(A158457(n), n=1..120) ; (End)
MATHEMATICA
lnp[{n_, a_}]:=Module[{sd=Total[IntegerDigits[n+1]]+Total[ IntegerDigits[ a]]-1}, While[PrimeQ[sd], sd--]; {n+1, sd}]; NestList[lnp, {0, 1}, 80][[All, 2]] (* Harvey P. Dale, May 28 2021 *)
CROSSREFS
Sequence in context: A196268 A251756 A357803 * A072905 A086481 A329507
KEYWORD
nonn,base,less
AUTHOR
EXTENSIONS
Entries checked by R. J. Mathar, May 21 2010
STATUS
approved