[go: up one dir, main page]

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”).

A261237
Number of steps needed when starting from (3^(n+1))-1 and repeatedly applying the map that replaces k with k - (sum of digits in base-3 representation of k) to encounter the first number whose base-3 representation begins with a digit other than 2.
4
1, 1, 2, 5, 13, 34, 92, 251, 687, 1885, 5184, 14292, 39557, 110094, 308351, 868716, 2458964, 6984467, 19890809, 56775186, 162427605, 465816503, 1339163192, 3858600035, 11138726760, 32199805820
OFFSET
0,3
COMMENTS
a(n) = How many numbers whose base-3 representation begins with digit "2" are encountered before (3^n)-1 is reached when starting from k = (3^(n+1))-1 and repeatedly applying the map that replaces k by k - (sum of digits in base-3 representation of k). Note that (3^n)-1 (in base-3: "222...", with digit "2" repeated n times) is not included in the count, although the starting point (3^(n+1))-1 is.
EXAMPLE
For n=0, we start from 3^(0+1) - 1 = 2 (also "2" in base-3), and subtract 2 to get 0, which doesn't begin with 2, thus a(0) = 1.
For n=1, we start from 3^(1+1) - 1 = 8 ("22" in base-3), and subtract 2*2 = 4 to get 4 ("11" in base-3) which doesn't begin with 2, thus a(1) = 1.
For n=2, we start from 3^(2+1) - 1 = 26 ("222" in base-3), and subtract first 6 to get 20 ("202" in base-3), from which we subtract 4, to get 16 ("121" in base-3), so in two steps we have reached the first such number that does not begin with "2" in base-3, thus a(2) = 2.
MATHEMATICA
Flatten@ Table[FirstPosition[#, k_ /; k != 2] &@ Map[First@ IntegerDigits[#, 3] &, NestWhileList[# - Total@ IntegerDigits[#, 3] &, 3^(n + 1) - 1, # > 3^n - 1 &]] - 1, {n, 0, 16}] (* Michael De Vlieger, Jun 27 2016, Version 10 *)
PROG
(C) /* Use the C-program given in A261234. */
(Scheme) (definec (A261237 n) (let loop ((k (- (A000244 (+ 1 n)) 1)) (s 0)) (if (< (A122586 k) 2) s (loop (* 2 (A054861 k)) (+ 1 s)))))
(PARI) a(n)=my(k=3^(n+1)-1, t=2*3^n, s); while(k>=t, k-=sumdigits(k, 3); s++); s \\ Charles R Greathouse IV, Aug 21 2015
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Antti Karttunen, Aug 16 2015
EXTENSIONS
Terms a(24) & a(25) from Antti Karttunen, Jun 27 2016
STATUS
approved