cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

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.

This page as a plain text file.
%I A261237 #27 Mar 30 2017 21:51:52
%S A261237 1,1,2,5,13,34,92,251,687,1885,5184,14292,39557,110094,308351,868716,
%T A261237 2458964,6984467,19890809,56775186,162427605,465816503,1339163192,
%U A261237 3858600035,11138726760,32199805820
%N 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.
%C A261237 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.
%e A261237 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.
%e A261237 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.
%e A261237 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.
%t A261237 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 *)
%o A261237 (C) /* Use the C-program given in A261234. */
%o A261237 (Scheme) (definec (A261237 n) (let loop ((k (- (A000244 (+ 1 n)) 1)) (s 0)) (if (< (A122586 k) 2) s (loop (* 2 (A054861 k)) (+ 1 s)))))
%o A261237 (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
%Y A261237 Cf. A000244, A054861, A122586, A261230, A261234, A261236.
%K A261237 nonn,base
%O A261237 0,3
%A A261237 _Antti Karttunen_, Aug 16 2015
%E A261237 Terms a(24) & a(25) from _Antti Karttunen_, Jun 27 2016