login
a(1) = 1, a(n) = a(n-1)/3 if a(n-1) is divisible by 3, otherwise a(n) = n - a(n-1).
1

%I #10 Jul 01 2021 07:19:59

%S 1,1,2,2,3,1,6,2,7,3,1,11,2,12,4,12,4,14,5,15,5,17,6,2,23,3,1,27,9,3,

%T 1,31,2,32,3,1,36,12,4,36,12,4,39,13,32,14,33,11,38,12,4,48,16,38,17,

%U 39,13,45,15,5,56,6,2,62,3,1,66,22,47,23,48,16,57,19,56,20,57,19,60,20,61,21,7,77,8

%N a(1) = 1, a(n) = a(n-1)/3 if a(n-1) is divisible by 3, otherwise a(n) = n - a(n-1).

%C See comments section of A345877.

%t a[1] = 1; a[n_] := a[n] = If[Divisible[a[n - 1], 3], a[n - 1]/3, n - a[n - 1]]; Array[a, 100] (* _Amiram Eldar_, Jun 29 2021 *)

%o (PARI) q=vector(100); q[1]=1; for(n=2, #q, q[n] = if(q[n-1]%3, n-q[n-1], q[n-1]/3)); q

%Y Cf. A345877.

%K nonn,easy

%O 1,3

%A _Altug Alkan_, Jun 28 2021