OFFSET
0,4
COMMENTS
The even terms in the Stern sequence, divided by 2.
LINKS
Alois P. Heinz, Table of n, a(n) for n = 0..16384
Jennifer Lansing, On the Stern sequence and a related sequence, Joint Mathematics Meetings, Baltimore, 2014.
Jennifer Lansing, Dissertation: On the Stern sequence and a related sequence, PhD dissertation, University of Illinois, 2014.
Jennifer Lansing, Largest Values for the Stern Sequence, J. Integer Seqs., 17 (2014), #14.7.5.
FORMULA
w(0)=0, w(1)=1, and w(3)=2. For n >= 1, w(n) satisfies the recurrences w(2n)=w(n), w(8n +/- 1)=w(4n +/- 1) + 2w(n), w(8n +/- 3)=w(4n +/- 1) + w(2n +/- 1) -w(n).
a(n) = A002487(3*n) / 2. - Joerg Arndt, Jun 20 2022
EXAMPLE
w(7) = w(8-1) = w(3)+2w(1) = 2+2 = 4.
w(11) = w(8+3) = w(4+1)+w(2+1)-w(1)=w(5)+w(3)-w(1) = 2+2-1 = 3.
Comment from N. J. A. Sloane, Jul 01 2014: (Start)
May be arranged as a triangle:
0
1
1
2 1 2
2 4 1 4 2
3 2 5 4 6 1 6 4 5 2 3
3 7 2 9 5 7 4 9 6 8 1 8 6 9 4 7 5 9 2 7 3
... (End)
MAPLE
A240388 := proc(n)
option remember;
local nloc;
if n <=1 then
n;
elif n = 3 then
2;
elif type(n, 'even') then
procname(n/2) ;
elif modp(n, 8) = 1 then
nloc := (n-1)/8 ;
procname(4*nloc+1)+2*procname(nloc) ;
elif modp(n, 8) = 7 then
nloc := (n+1)/8 ;
procname(4*nloc-1)+2*procname(nloc) ;
elif modp(n, 8) = 3 then
nloc := (n-3)/8 ;
procname(4*nloc+1)+procname(2*nloc+1)-procname(nloc) ;
else
nloc := (n+3)/8 ;
procname(4*nloc-1)+procname(2*nloc-1)-procname(nloc) ;
end if;
end proc: # R. J. Mathar, Jul 05 2014
# second Maple program:
b:= proc(n) option remember; `if`(n<2, n,
(q-> b(q)+(n-2*q)*b(n-q))(iquo(n, 2)))
end:
a:= n-> b(3*n)/2:
seq(a(n), n=0..128); # Alois P. Heinz, Jun 20 2022
MATHEMATICA
Clear[s]; s[0] = 0; s[1] = 1; s[n_?EvenQ] := s[n] = s[n/2];
s[n_?OddQ] :=
s[n] = s[(n + 1)/2] + s[(n - 1)/2] (* For the Stern sequence *)
Clear[w]; w[n_] = 1/2 s[3 n]
PROG
(PARI) a(n)=my(a=1, b=0); n*=3; while(n>0, if(n%2, b+=a, a+=b); n>>=1); b/2 \\ Charles R Greathouse IV, May 27 2014
(Python)
from functools import reduce
def A240388(n): return sum(reduce(lambda x, y:(x[0], x[0]+x[1]) if int(y) else (x[0]+x[1], x[1]), bin(3*n)[-1:2:-1], (1, 0)))//2 # Chai Wah Wu, Jun 20 2022
CROSSREFS
KEYWORD
AUTHOR
Jennifer Lansing, Apr 04 2014
STATUS
approved