OFFSET
0,2
COMMENTS
A variation on Stern's diatomic sequence.
LINKS
G. C. Greubel, Table of n, a(n) for n = 0..5000
Michael Gilleland, Some Self-Similar Integer Sequences
Ilya Gutkovskiy, Extended graphical example
Eric Weisstein's World of Mathematics, Stern's Diatomic Series
EXAMPLE
a(0) = 0;
a(1) = 2;
a(2) = a(2*1) = sopf(a(1)) = 2;
a(3) = a(2*1+1) = a(1) + a(2) = 4;
a(4) = a(2*2) = sopf(a(2)) = 2;
a(5) = a(2*2+1) = a(2) + a(3) = 6;
a(6) = a(2*3) = sopf(a(3)) = 2, etc.
MATHEMATICA
a[0] = 0; a[1] = 2; a[n_] := If[EvenQ[n], DivisorSum[a[n/2], # &, PrimeQ[#] &], a[(n - 1)/2] + a[(n + 1)/2]]; Table[a[n], {n, 0, 90}]
PROG
(PARI) a(n) = if (n==0, 0, if (n ==1, 2, if (n%2, a((n-1)/2) + a((n+1)/2), vecsum(factor(a(n/2))[, 1])))); \\ Michel Marcus, Dec 17 2017
CROSSREFS
KEYWORD
nonn,look
AUTHOR
Ilya Gutkovskiy, May 19 2017
STATUS
approved