login
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

%I #25 Jan 03 2025 20:52:13

%S 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,

%T 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,

%U 2,1,1,2,2,2,1,2,2,2,2,3,2,2,2,3,3,2,2,2,2,2

%N 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.

%H Robert Israel, <a href="/A037827/b037827.txt">Table of n, a(n) for n = 1..10000</a>

%F From _Robert Israel_, Oct 16 2015: (Start)

%F 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))).

%F For n >= 4, a(n) - a(floor(n/4)) = 0 if n == 1, 2, 3, 6, 7, or 11 (mod 16), 1 otherwise. (End)

%p A037827 := proc(n)

%p a := 0 ;

%p dgs := convert(n,base,4);

%p for i from 2 to nops(dgs) do

%p if op(i,dgs)>=op(i-1,dgs) then

%p a := a+1 ;

%p end if;

%p end do:

%p a ;

%p end proc: # _R. J. Mathar_, Oct 16 2015

%p S:= [1,2,3,6,7,11]:

%p f:= proc(n) option remember;

%p procname(floor(n/4)) + `if`(has(S,n mod 16),0,1)

%p end proc:

%p f(0):= 0:

%p seq(f(n),n=1..100); # _Robert Israel_, Oct 16 2015

%o (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

%o (Python)

%o def A037827(n):

%o s = '0'*(n.bit_length()&1)+bin(n)[2:]

%o 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

%Y Cf. A037811.

%K nonn,base

%O 1,16

%A _Clark Kimberling_

%E Sign in name corrected by _R. J. Mathar_, Oct 16 2015