login
Numbers whose base-9 representation has an even number of runs.
4

%I #11 Feb 20 2023 12:42:31

%S 9,11,12,13,14,15,16,17,18,19,21,22,23,24,25,26,27,28,29,31,32,33,34,

%T 35,36,37,38,39,41,42,43,44,45,46,47,48,49,51,52,53,54,55,56,57,58,59,

%U 61,62,63,64,65,66,67,68,69,71,72,73,74,75,76,77,78,79,81,90,92,93,94,95,96,97,98,101,111,121,131,141

%N Numbers whose base-9 representation has an even number of runs.

%p isA043698 := proc(n)

%p local dgs,runs,i ;

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

%p runs :=1 ;

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

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

%p runs := runs+1 ;

%p end if;

%p end do:

%p if type(runs,'even') then

%p true;

%p else

%p false;

%p end if;

%p end proc:

%p A043698 := proc(n)

%p option remember;

%p local a;

%p if n = 1 then

%p 9;

%p else

%p for a from procname(n-1)+1 do

%p if isA043698(a) then

%p return a ;

%p end if;

%p end do:

%p end if

%p end proc:

%p seq(A043698(n),n=1..120) ; # _R. J. Mathar_, Feb 20 2023

%K nonn,base

%O 1,1

%A _Clark Kimberling_