|
|
A309311
|
|
a(1)=1, a(2)=2; thereafter a(n+1) = Sum_{i=m..n} a(i) where m = (n+1)-k and k is the last digit of a(n), except if k=0, k=1, or k>n then a(n+1) = Sum_{i=1..n} a(i).
|
|
1
|
|
|
1, 2, 3, 6, 12, 18, 42, 60, 144, 264, 510, 1062, 1572, 2634, 5778, 12024, 22008, 45852, 67860, 159852, 227712, 387564, 842988, 1765860, 3543828, 7041516, 13809468, 27778788, 55397724, 104027496, 211598820, 426741468, 849939108, 1696334388, 3385627260, 6785383692
(list;
graph;
refs;
listen;
history;
text;
internal format)
|
|
|
OFFSET
|
1,2
|
|
COMMENTS
|
Briefly, a(n+1) is the sum of the previous terms up to a number m which is defined by the last digit of a(n).
|
|
LINKS
|
|
|
EXAMPLE
|
Calculating a(8):
8=n+1, n=7
a(7)=42 so k=2
m=n+1-k=6
a(8)=Sum_{i=6..7} a(i)=a(6)+a(7)
a(8)=60
|
|
MAPLE
|
A[1]:= 1: S[0]:= 0: S[1]:= 1:
A[2]:= 2: S[2]:= 3:
for n from 2 to 99 do
k:= A[n] mod 10;
if k <= 1 or k > n then A[n+1]:= S[n] else A[n+1]:= S[n] - S[n-k] fi;
S[n+1]:= S[n]+A[n+1]
od:
|
|
MATHEMATICA
|
a[1] = 1; a[2] = 2; a[n_] := a[n] = Module[{k = Mod[a[n - 1], 10]}, m = If[k > n - 1 || k == 0, 1, n - k]; Sum[a[i], {i, m, n - 1}]]; Array[a, 36] (* Amiram Eldar, Jul 23 2019 *)
|
|
CROSSREFS
|
|
|
KEYWORD
|
nonn,base,easy
|
|
AUTHOR
|
|
|
EXTENSIONS
|
|
|
STATUS
|
approved
|
|
|
|