|
|
A053737
|
|
Sum of digits of (n written in base 4).
|
|
50
|
|
|
0, 1, 2, 3, 1, 2, 3, 4, 2, 3, 4, 5, 3, 4, 5, 6, 1, 2, 3, 4, 2, 3, 4, 5, 3, 4, 5, 6, 4, 5, 6, 7, 2, 3, 4, 5, 3, 4, 5, 6, 4, 5, 6, 7, 5, 6, 7, 8, 3, 4, 5, 6, 4, 5, 6, 7, 5, 6, 7, 8, 6, 7, 8, 9, 1, 2, 3, 4, 2, 3, 4, 5, 3, 4, 5, 6, 4, 5, 6, 7, 2, 3, 4, 5, 3, 4, 5, 6, 4, 5, 6, 7, 5, 6, 7, 8, 3, 4, 5, 6, 4, 5, 6, 7, 5
(list;
graph;
refs;
listen;
history;
text;
internal format)
|
|
|
OFFSET
|
0,3
|
|
COMMENTS
|
Also the fixed point of the morphism 0->{0,1,2,3}, 1->{1,2,3,4}, 2->{2,3,4,5}, etc. - Robert G. Wilson v, Jul 27 2006
|
|
LINKS
|
Jeffrey O. Shallit, Problem 6450, Advanced Problems, The American Mathematical Monthly, Vol. 91, No. 1 (1984), pp. 59-60; Two series, solution to Problem 6450, ibid., Vol. 92, No. 7 (1985), pp. 513-514.
Eric Weisstein's World of Mathematics, Digit Sum.
|
|
FORMULA
|
a(0) = 0, a(4n+i) = a(n)+i for 0 <= i <= 3.
a(n) = n - 3*Sum_{k>0} floor(n/4^k) = n - 3*A054893(n). (End)
G.f.: (Sum_{k>=0} (x^(4^k) + 2*x^(2*4^k) + 3*x^(3*4^k))/(1 + x^(4^k) + x^(2*4^k) + x^(3*4^k))/(1-x). - Franklin T. Adams-Watters, Nov 03 2005
a(0) = 0; a(n) = a(n - 4^floor(log_4(n))) + 1. - Ilya Gutkovskiy, Aug 23 2019
Sum_{n>=1} a(n)/(n*(n+1)) = 4*log(4)/3 (Shallit, 1984). - Amiram Eldar, Jun 03 2021
|
|
EXAMPLE
|
a(20) = 1+1+0 = 2 because 20 is written as 110 base 4.
This can be written as a triangle (cf. A000120):
0,
1,2,3,
1,2,3,4,2,3,4,5,3,4,5,6,
1,2,3,4,2,3,4,5,3,4,5,6,4,5,6,7,2,3,4,5,3,4,5,6,4,5,6,7,5,6,7,8,3,4,5,6,4,5,6,7,5,6,7,8,6,7,8,9,
1,2,3,4,2,3,4,5,3,4,5,6,4,5,6,7,2,3,4,5,3,4,5,6,4,5,6,7,5,6,7,8,3,4,5,6,4,...
where the rows converge to A173524.
(End)
|
|
MAPLE
|
add(d, d=convert(n, base, 4)) ;
|
|
MATHEMATICA
|
Table[Plus @@ IntegerDigits[n, 4], {n, 0, 100}] (* or *)
Nest[ Flatten[ #1 /. a_Integer -> {a, a+1, a+2, a+3}] &, {0}, 4] (* Robert G. Wilson v, Jul 27 2006 *)
DigitSum[Range[0, 100], 4] (* Paolo Xausa, Aug 01 2024 *)
|
|
PROG
|
(PARI) a(n)=if(n<1, 0, if(n%4, a(n-1)+1, a(n/4)))
(Haskell)
a053737 n = if n == 0 then 0 else a053737 m + r where (m, r) = divMod n 4
(MATLAB) for u=0:104; sol(u+1)=sum(dec2base(u, 4)-'0'); end
|
|
CROSSREFS
|
Sum of digits of n written in bases 2-16: A000120, A053735, this sequence, A053824, A053827, A053828, A053829, A053830, A007953, A053831, A053832, A053833, A053834, A053835, A053836.
Related base-4 sequences: A053737, A230631, A230632, A010064, A230633, A230634, A230635, A230636, A230637, A230638, A010065 (trajectory of 1).
|
|
KEYWORD
|
base,nonn,easy
|
|
AUTHOR
|
|
|
STATUS
|
approved
|
|
|
|