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.

A348338 a(n) is the number of distinct numbers of steps required for the last n digits of integers to repeat themselves by iterating the map m -> 2*m.

This page as a plain text file.
%I A348338 #33 Nov 19 2021 07:42:35
%S A348338 1,4,9,15,23,33,45,59,75,93,113,135,159,185,213,243,274,307,342,379,
%T A348338 418,459,502,547,594,643,694,747,802,859,918,979,1042,1107,1174,1243,
%U A348338 1314,1387,1462,1539,1618,1699,1782,1867,1954,2043,2134,2227,2322,2419,2518
%N A348338 a(n) is the number of distinct numbers of steps required for the last n digits of integers to repeat themselves by iterating the map m -> 2*m.
%C A348338 For n >= 1, the largest number of steps required is 4*5^(n-1) + n.
%F A348338 For n >= 1, a(n) = a(n-1) + 2*n - ceiling(log_5 ((n+1)/16)), or a(n) = n^2 + n + 2 - Sum_{2..n} ceiling(log_5 ((i+1)/16)).
%e A348338 a(1) = 4. As shown below, integers ending with 0, 5, {2, 4, 6 or 8}, and {1, 3, 7, or 9} require 1, 2, 4, and 5 steps to repeat the last digit, respectively. Therefore, the distinct numbers of steps are {1, 2, 4, 5} and a(1) = 4.
%e A348338           _          1=>2===>4<=7
%e A348338          v \            ^    v
%e A348338      5==>0==         3=>6<===8<=9
%e A348338 a(2) = 9 because the distinct steps are {1, 2, 3, 4, 5, 6, 20, 21, 22}, as shown by the paths of the last two digits of integers.
%e A348338               _         1,51         27,77  29,79  33,83  41,91          7,57
%e A348338              v \           v           v      v      v      v           v
%e A348338 25,75==>50==>0==             2         54     58     66     82        14
%e A348338                                v       v      v      v      v        v
%e A348338                                 4=====>8=====>16====>32====>64====>28
%e A348338 5,55         35,85              ^                                  v
%e A348338    v         v       13,63=>26=>52                                 56<=78<=39,89
%e A348338    10       70                  ^                                  v
%e A348338      v     v         19,69=>38=>76                                 12<==6<==3,53
%e A348338      20==>40                    ^                                  v
%e A348338       ^   v          47,97=>94=>88                                 24<=62<=31,81
%e A348338      60<==80                    ^                                  v
%e A348338      ^     ^         11,61=>22=>44                                 48<=74<=37,87
%e A348338    30       90                  ^                                  v
%e A348338    ^         ^                  72<====36<====68<====84<====92<====96
%e A348338 15,65        45,95             ^       ^      ^      ^      ^        ^
%e A348338                              86        18     34     42     46        98
%e A348338                             ^          ^      ^      ^      ^           ^
%e A348338                         43,93         9,59  17,67  21,71  23,73         49,99
%e A348338 a(3) = 15 because the distinct steps for n = 3 are {1, 2, 3, 4, 5, 6, 7, 20, 21, 22, 23, 100, 101, 102, 103}.
%o A348338 (Python)
%o A348338 def tail(m):
%o A348338     global n; s = str(m)
%o A348338     return m if len(s) <= n else int(s[-n:])
%o A348338 for n in range(1, 9):
%o A348338     M = []
%o A348338     for i in range(10**n):
%o A348338         t = i; L = [t]
%o A348338         while i >= 0:
%o A348338             t = tail(2*t)
%o A348338             if t not in L: L.append(t)
%o A348338             else: break
%o A348338         d = len(L)
%o A348338         if d not in M: M.append(d)
%o A348338     print(len(M), end = ', ')
%o A348338 (Python)
%o A348338 def A348338(n):
%o A348338     m, s = 10**n, set()
%o A348338     for k in range(m):
%o A348338         c, k2, kset = 0, k, set()
%o A348338         while k2 not in kset:
%o A348338             kset.add(k2)
%o A348338             c += 1
%o A348338             k2 = 2*k2 % m
%o A348338         s.add(c)
%o A348338     return len(s) # _Chai Wah Wu_, Oct 19 2021
%o A348338 (PARI) a(n) = n + (n+1)*(n-1-t=(logint(5*(n+1)>>4+(n<3), 5))) + 4*5^t - (2-n)*(n<3); \\ _Jinyuan Wang_, Nov 02 2021
%Y A348338 Cf. A005843, A348339.
%K A348338 nonn,base
%O A348338 0,2
%A A348338 _Ya-Ping Lu_, Oct 13 2021
%E A348338 a(9)-a(10) from _Martin Ehrenstein_, Oct 20 2021
%E A348338 a(0) prepended and a(11)-a(14) from _Martin Ehrenstein_, Oct 29 2021
%E A348338 More terms from _Jinyuan Wang_, Nov 02 2021