|
|
A081603
|
|
Number of 2's in ternary representation of n.
|
|
47
|
|
|
0, 0, 1, 0, 0, 1, 1, 1, 2, 0, 0, 1, 0, 0, 1, 1, 1, 2, 1, 1, 2, 1, 1, 2, 2, 2, 3, 0, 0, 1, 0, 0, 1, 1, 1, 2, 0, 0, 1, 0, 0, 1, 1, 1, 2, 1, 1, 2, 1, 1, 2, 2, 2, 3, 1, 1, 2, 1, 1, 2, 2, 2, 3, 1, 1, 2, 1, 1, 2, 2, 2, 3, 2, 2, 3, 2, 2, 3, 3, 3, 4, 0, 0, 1, 0, 0, 1, 1, 1, 2, 0, 0, 1, 0, 0, 1, 1, 1, 2, 1, 1, 2, 1, 1, 2
(list;
graph;
refs;
listen;
history;
text;
internal format)
|
|
|
OFFSET
|
0,9
|
|
COMMENTS
|
Fixed point of the morphism: 0 ->001; 1 ->112; 2 ->223; 3 ->334, etc., starting from a(0)=0. - Philippe Deléham, Oct 26 2011
|
|
LINKS
|
Eric Weisstein's World of Mathematics, Ternary.
|
|
FORMULA
|
a(n) = floor(n/2) if n < 3, otherwise a(floor(n/3)) + floor((n mod 3)/2).
|
|
MAPLE
|
local a, d ;
a := 0 ;
for d in convert(n, base, 3) do
if d= 2 then
a := a+1 ;
end if;
end do:
a;
|
|
MATHEMATICA
|
Nest[ Flatten[# /. a_Integer -> {a, a, a + 1}] &, {0}, 5] (* Robert G. Wilson v, May 20 2014 *)
|
|
PROG
|
(Haskell)
a081603 0 = 0
a081603 n = a081603 n' + m `div` 2 where (n', m) = divMod n 3
|
|
CROSSREFS
|
|
|
KEYWORD
|
nonn,base
|
|
AUTHOR
|
|
|
STATUS
|
approved
|
|
|
|