OFFSET
1,4
COMMENTS
The first term of the sequence, a(1), is called "the seed".
LINKS
Carole Dubois, Table of n, a(n) for n = 1..5001
EXAMPLE
As n=7 is odd, a(7) = sum of all even digits to the left of a(7) = 0 + 2 + 2 + 2 = 6;
as n=8 is even, a(8) = the sum of all odd digits to the left of a(8) = 1 + 1 = 2);
as n=9 is odd, a(9) = the sum of all even digits to the left of a(9) = 0 + 2 + 2 + 2 + 6 + 2 = 14; etc.
MATHEMATICA
Block[{a = {1}, s}, Array[Set[s[#], 0] &, 9]; Do[(MapIndexed[AddTo[s[First[#2]], #1] &, #]; AppendTo[a, Total@ Map[# s[#] &, If[EvenQ@ i, {2, 4, 6, 8}, {1, 3, 5, 7, 9}]]]) &@ Most@ DigitCount@ Last@ a, {i, 69}]; a ] (* Michael De Vlieger, Dec 10 2020 *)
PROG
(PARI) sumo(d) = sum(k=1, #d, if (d[k] % 2, d[k]));
sume(d) = sum(k=1, #d, if (!(d[k] % 2), d[k]));
esum(va, k) = sum(i=1, k, sumo(digits(va[i])));
osum(va, k) = sum(i=1, k, sume(digits(va[i])));
lista(nn) = {my(va = vector(nn)); va[1] = 1; va[2] = 1; for (n=3, nn, va[n] = if (n % 2, osum(va, n-1), esum(va, n-1)); ); va; } \\ Michel Marcus, Dec 10 2020
(Python)
def aupto(nn):
seed, s = 1, [0, 0]
alst = [None, seed]
for n in range(2, nn+1):
s[0] += sum(int(d) for d in str(alst[-1]) if d in "02468")
s[1] += sum(int(d) for d in str(alst[-1]) if d in "13579")
alst.append(s[not n%2])
return alst[1:] # use alst[n] for a(n)
print(aupto(70)) # Michael S. Branicky, Dec 11 2020
CROSSREFS
KEYWORD
base,nonn
AUTHOR
Eric Angelini and Carole Dubois, Nov 23 2020
STATUS
approved