OFFSET
1,2
LINKS
Alois P. Heinz, Table of n, a(n) for n = 1..1000
FORMULA
a(1)=1, a(2)=2; a(n+1)=2a(n)-a(n-1)+sod(a(n)) (sod = "sum of digits"). - Farideh Firoozbakht, Oct 01 2009
Asymptotically it seems a(n)~c*n^2*log(n) for c~1.99... - Benoit Cloitre, Oct 07 2009
MAPLE
b:= proc(n) option remember; local m;
m:= a(n);
`if`(n=1, 0, b(n-1));
while m>0 do %+ irem(m, 10, 'm') od; %
end:
a:= proc(n) option remember;
`if`(n=1, 1, a(n-1) +b(n-1))
end:
seq(a(n), n=1..50); # Alois P. Heinz, Jun 01 2010
MATHEMATICA
a[1]=1; a[2]=2; a[n_]:=a[n]=2*a[n-1]-a[n-2]+Apply[Plus, IntegerDigits[a[n-1]]]; Table[a[n], {n, 100}] (* Farideh Firoozbakht, Oct 01 2009 *)
a[1] = 1; a[n_] := a[n] = a[n - 1] + Plus @@ Flatten[ Map[ IntegerDigits, Array[a, n - 1]]]; Array[a, 100] (* Robert G. Wilson v, Oct 01 2009 *)
PROG
(Python)
from itertools import islice
def agen(): # generator of terms
an, anp1 = 1, 2
while True:
yield an
an, anp1 = anp1, 2*anp1 - an + sum(map(int, str(anp1)))
print(list(islice(agen(), 44))) # Michael S. Branicky, Oct 01 2024
CROSSREFS
KEYWORD
nonn,base
AUTHOR
N. J. A. Sloane, Oct 07 2009, based on a posting to the Sequence Fans Mailing List by Eric Angelini, Oct 01 2009
EXTENSIONS
More terms from Alois P. Heinz, Oct 01 2009
STATUS
approved