login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

A037827
Number of i such that d(i) >= d(i-1), where Sum_{i=0..m} d(i)*4^i is the base-4 representation of n.
2
0, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 1, 1, 1, 1, 2, 1, 1, 1, 2, 2, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 2, 1, 1, 1, 2, 2, 1, 1, 2, 2, 2, 1, 1, 1, 1, 1, 2, 1, 1, 1, 2, 2, 1, 1, 2, 2, 2, 1, 2, 2, 2, 2, 3, 2, 2, 2, 2, 2, 1, 1, 2, 2, 2, 1, 2, 2, 2, 2, 3, 2, 2, 2, 3, 3, 2, 2, 2, 2, 2
OFFSET
1,16
LINKS
FORMULA
From Robert Israel, Oct 16 2015: (Start)
G.f.: (1-x)^(-1) * Sum_{j>=0} x^(4^(j+1)*(1-x^(4^j))*(1+x^(4^j)+x^(4*4^j)+x^(5*4^j)+x^(6*4^j)+x^(8*4^j)+x^(9*4^j)+x^(10*4^j)+x^(11*4^j)+x^(12*4^j))/(1-x^(4^(j+2))).
For n >= 4, a(n) - a(floor(n/4)) = 0 if n == 1, 2, 3, 6, 7, or 11 (mod 16), 1 otherwise. (End)
MAPLE
A037827 := proc(n)
a := 0 ;
dgs := convert(n, base, 4);
for i from 2 to nops(dgs) do
if op(i, dgs)>=op(i-1, dgs) then
a := a+1 ;
end if;
end do:
a ;
end proc: # R. J. Mathar, Oct 16 2015
S:= [1, 2, 3, 6, 7, 11]:
f:= proc(n) option remember;
procname(floor(n/4)) + `if`(has(S, n mod 16), 0, 1)
end proc:
f(0):= 0:
seq(f(n), n=1..100); # Robert Israel, Oct 16 2015
PROG
(PARI) a(n) = {my(d = Vecrev(digits(n, 4))); my(dd = vector(#d-1, k, d[k+1] - d[k])); #select(x->(x>=0), dd); } \\ Michel Marcus, Oct 16 2015
(Python)
def A037827(n):
s = '0'*(n.bit_length()&1)+bin(n)[2:]
return sum(1 for i in range(0, len(s)-2, 2) if s[i:i+2]>=s[i+2:i+4]) # Chai Wah Wu, Feb 02 2023
CROSSREFS
Cf. A037811.
Sequence in context: A299236 A374076 A353970 * A086074 A180601 A331048
KEYWORD
nonn,base
EXTENSIONS
Sign in name corrected by R. J. Mathar, Oct 16 2015
STATUS
approved