%I #14 Aug 08 2015 21:43:10
%S 1,2,1,8,7,8,1,2,1,26,25,26,19,20,19,26,25,26,1,2,1,8,7,8,1,2,1,80,79,
%T 80,73,74,73,80,79,80,55,56,55,62,61,62,55,56,55,80,79,80,73,74,73,80,
%U 79,80,1,2,1,8,7,8,1,2,1,26,25,26,19,20,19,26,25,26,1,2,1,8,7,8,1,2,1
%N a(1)=1, then bracketing n with powers of 3 as f(t)=3^t for f(t) < n <= f(t+1), a(n) = f(t+1) - a(n-f(t)).
%F a(n+1) = 1 + Sum_{k=1..n} (-1)^k*(2-3*3^valuation(k, 3)).
%F a(n) = A064235(n) - a(n - A064235(n)/3). - _R. J. Mathar_, Nov 06 2011
%p A105672 := proc(n)
%p option remember;
%p if n = 1 then
%p 1;
%p else
%p fn1 := A064235(n) ;
%p fn := fn1/3 ;
%p fn1-procname(n-fn) ;
%p end if;
%p end proc:
%p seq(A105672(n),n=1..80) ; # _R. J. Mathar_, Nov 06 2011
%t A064235[n_] := 3^Ceiling[Log[3, n]]; a[1] = 1; a[n_] := a[n] = A064235[n] - a[n - A064235[n]/3]; Table[a[n], {n, 1, 81}] (* _Jean-François Alcover_, Jul 09 2013, after _R. J. Mathar_ *)
%o (PARI) b(n,m)=if(n<2,1,m*m^floor(log(n-1)/log(m))-b(n-m^floor(log(n-1)/log(m)),m))
%Y Cf. A105669, A105670, A093347, A093348.
%K nonn
%O 1,2
%A _Benoit Cloitre_, May 03 2005