login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
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:
seq(A[i], i=1..100); # Robert Israel, Sep 01 2019
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
Sequence in context: A093687 A000423 A007335 * A361693 A103070 A233422
KEYWORD
nonn,base,easy
AUTHOR
Eder Vanzei, Jul 22 2019
EXTENSIONS
More terms from Amiram Eldar, Jul 23 2019
Edited by N. J. A. Sloane, Aug 31 2019
STATUS
approved

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified April 19 05:19 EDT 2024. Contains 371782 sequences. (Running on oeis4.)