A112395 Next term is the sum of the previous 10 digits in the sequence.
0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 2, 4, 8, 16, 23, 28, 37, 44, 40, 37, 42, 38, 39, 43, 46, 46, 50, 44, 40, 37, 37, 37, 42, 40, 40, 34, 31, 25, 26, 30, 29, 33, 35, 36, 37, 44, 41, 40, 36, 36, 35, 35, 38, 45, 45, 45, 46, 48, 49, 53, 52, 50, 45, 42, 35, 35, 36, 40, 35, 37, 39, 43, 41
Offset: 1
Examples
0 + 0 + 1 + 1 + 2 + 4 + 8 + 1 + 6 = 23
Links
- Michael S. Branicky, Table of n, a(n) for n = 1..331 (through first loop)
Programs
-
Mathematica
a[1] = a[2] = a[3] = a[4] = a[5] = a[6] = a[7] = a[8] = a[9] = 0; a[10] = 1; a[n_] := a[n] = Plus @@ Take[ Flatten@Table[IntegerDigits[a[i]], {i, n - 10, n - 1}], -10]; Array[a, 74] (* Robert G. Wilson v, Dec 09 2005 *)
-
Python
from itertools import islice def agen(): # generator of terms last10 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 1] print(last10[:0]) yield from last10 while True: an = sum(last10) yield an d = list(map(int, str(an))) last10 = last10[-max(10-len(d), 0):] + d[-min(len(d), 10):] print(list(islice(agen(), 74))) # Michael S. Branicky, Oct 03 2024
Comments