login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

A345886
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
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, 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, 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
OFFSET
1,3
COMMENTS
See comments section of A345877.
MATHEMATICA
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 *)
PROG
(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
CROSSREFS
Cf. A345877.
Sequence in context: A215222 A219865 A016539 * A373880 A220349 A273218
KEYWORD
nonn,easy
AUTHOR
Altug Alkan, Jun 28 2021
STATUS
approved