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.

Showing 1-4 of 4 results.

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.

Original entry on oeis.org

1, 4, 9, 15, 23, 33, 45, 59, 75, 93, 113, 135, 159, 185, 213, 243, 274, 307, 342, 379, 418, 459, 502, 547, 594, 643, 694, 747, 802, 859, 918, 979, 1042, 1107, 1174, 1243, 1314, 1387, 1462, 1539, 1618, 1699, 1782, 1867, 1954, 2043, 2134, 2227, 2322, 2419, 2518
Offset: 0

Views

Author

Ya-Ping Lu, Oct 13 2021

Keywords

Comments

For n >= 1, the largest number of steps required is 4*5^(n-1) + n.

Examples

			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.
          _          1=>2===>4<=7
         v \            ^    v
     5==>0==         3=>6<===8<=9
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.
              _         1,51         27,77  29,79  33,83  41,91          7,57
             v \           v           v      v      v      v           v
25,75==>50==>0==             2         54     58     66     82        14
                               v       v      v      v      v        v
                                4=====>8=====>16====>32====>64====>28
5,55         35,85              ^                                  v
   v         v       13,63=>26=>52                                 56<=78<=39,89
   10       70                  ^                                  v
     v     v         19,69=>38=>76                                 12<==6<==3,53
     20==>40                    ^                                  v
      ^   v          47,97=>94=>88                                 24<=62<=31,81
     60<==80                    ^                                  v
     ^     ^         11,61=>22=>44                                 48<=74<=37,87
   30       90                  ^                                  v
   ^         ^                  72<====36<====68<====84<====92<====96
15,65        45,95             ^       ^      ^      ^      ^        ^
                             86        18     34     42     46        98
                            ^          ^      ^      ^      ^           ^
                        43,93         9,59  17,67  21,71  23,73         49,99
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}.
		

Crossrefs

Programs

  • 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
  • Python
    def tail(m):
        global n; s = str(m)
        return m if len(s) <= n else int(s[-n:])
    for n in range(1, 9):
        M = []
        for i in range(10**n):
            t = i; L = [t]
            while i >= 0:
                t = tail(2*t)
                if t not in L: L.append(t)
                else: break
            d = len(L)
            if d not in M: M.append(d)
        print(len(M), end = ', ')
    
  • Python
    def A348338(n):
        m, s = 10**n, set()
        for k in range(m):
            c, k2, kset = 0, k, set()
            while k2 not in kset:
                kset.add(k2)
                c += 1
                k2 = 2*k2 % m
            s.add(c)
        return len(s) # Chai Wah Wu, Oct 19 2021
    

Formula

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

Extensions

a(9)-a(10) from Martin Ehrenstein, Oct 20 2021
a(0) prepended and a(11)-a(14) from Martin Ehrenstein, Oct 29 2021
More terms from Jinyuan Wang, Nov 02 2021

A349744 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 -> m^3.

Original entry on oeis.org

2, 5, 7, 12, 15, 18, 29, 42, 57, 87, 108
Offset: 1

Views

Author

Ya-Ping Lu, Nov 28 2021

Keywords

Examples

			a(1) = 2. The paths of the last digit of integers resulted from iterating the map, m -> m^3, are: 0->0; 1->1; 2->8->2; 3->7->3; 4->4; 5->5; 6->6; 7->3->7; 8->2->8; 9->9. Integers ending with 0, 1, 4, 5, 6 or 9 take 1 step to repeat the last digit. Integers ending with 2, 3, 7 or 8 takes 2 steps to repeat the last digit. Therefore, for n = 1, the distinct numbers of steps s(1) = {1, 2} and a(1) = 2.
a(2) = 5 because the distinct steps for the last two digits of integers to repeat themselves by iterating the map, m -> m^3, is s(2) = {1, 2, 3, 4, 5}.
a(3) = 7:  s(3) = s(2) + {20, 21}.
a(4) = 12: s(4) = s(3) + {6, 22, 100..102}.
a(5) = 15: s(5) = s(4) + {500..502}.
a(6) = 18: s(6) = s(5) + {2500..2502}.
a(7) = 29: s(7) = s(6) + {8..10, 40, 200, 1000, 5000, 12500..12502, 25000}
a(8) = 42: s(8) = s(7) + {16..18, 80, 400, 2000, 10000, 50000, 62500..62502, 125000, 250000}.
a(9) = 57: s(9) = s(8) + {32..34, 160, 800, 4000, 20000, 100000, 312500..312502, 500000, 625000, 1250000, 2500000}.
a(10)= 87: s(10)= s(9) + {7, 11, 19, 23, 35, 64..67, 103, 320, 503, 1600, 2503, 8000, 12503, 40000, 62503, 200000, 312503, 1000000, 1562500..1562503, 3125000, 5000000, 6250000, 12500000, 25000000}.
a(11)=108: s(11)=s(10) + {128..131, 640, 3200, 16000, 80000, 400000, 2000000, 7812500..7812503, 10000000, 15625000, 31250000, 50000000, 62500000, 125000000, 250000000}.
		

Crossrefs

Programs

  • Python
    for n in range(1, 12):
        b = 10**n; M = set()
        for i in range(b):
            t = i; L = set()
            while t not in L: L.add(t); t = (t**3)%b
            d = len(L)
            if d not in M: M.add(d)
        print(len(M), end = ', ')

A349786 Prime numbers p such that iterating the map m -> m^2 on p generates a number ending with p.

Original entry on oeis.org

5, 41, 61, 241, 281, 401, 521, 601, 641, 761, 881, 1201, 1361, 1601, 2081, 2161, 2801, 3041, 3121, 3361, 3761, 4001, 4241, 4481, 4561, 4721, 4801, 5281, 5441, 5521, 6481, 6961, 7121, 7681, 7841, 8081, 8161, 8641, 9041, 9281, 9521, 9601, 11681, 12161, 12641
Offset: 1

Views

Author

Ya-Ping Lu, Nov 30 2021

Keywords

Examples

			41 is a term because iterating the map, m -> m^2, on 41 gives: 41 -> 1681 -> 2825761 -> 7984925229121 -> 63759030914653054346432641, which ends with 41.
		

Crossrefs

Programs

  • Mathematica
    q[n_] := NestWhileList[Mod[#^2, 10^IntegerLength[n]] &, n, UnsameQ, All][[-1]] == n; Select[Range[10^4], PrimeQ[#] && q[#] &] (* Amiram Eldar, Nov 30 2021 *)
  • Python
    from sympy import nextprime
    p0 = 1
    while p0 < 13000:
        p = nextprime(p0); s = len(str(p)); t = p; L = set()
        while t not in L: L.add(t); t = (t*t) % 10**s
        if t == p: print(p, end = ', ')
        p0 = p

A350588 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 -> m^5.

Original entry on oeis.org

1, 2, 3, 4, 6, 9, 14, 23, 33, 45, 59, 75, 93, 113, 135, 159, 184, 211, 240, 271, 304, 339, 376, 415, 456, 499, 544, 591, 640, 691, 744, 799, 855, 913, 973, 1035, 1099, 1165, 1233, 1303, 1375, 1449, 1525, 1603, 1683, 1765, 1849, 1935, 2023, 2113, 2205, 2299
Offset: 1

Views

Author

Ya-Ping Lu, Jan 07 2022

Keywords

Examples

			a(1) = 1. It takes one step to repeat the last digit by iterating the map on an integer. For example, 2^5 = 32 and 9^5 = 59049. Thus, the distinct number of steps for n = 1 is {1} and a(1) = 1.
a(2) = 2. It takes 1 or 2 steps for an integer to repeat its last two digits. For example, 24 -> 7962624; 27 -> 14348907 -> 608266787713357709119683992618861307. Thus, a(2) = 2: {1, 2}.
a(3)  =  3: {1..3}.
a(4)  =  4: {1..4}.
a(5)  =  6: {1..6}.
a(6)  =  9: {1..9}.
a(7)  = 14: {1..14}.
a(8)  = 23: {1..23}.
a(9)  = 33: {1..24, 32..40}.
a(10) = 45: {1..25, 32..41, 64..73}.
a(11) = 59: {1..26, 32..42, 64..74, 128..138}.
		

Crossrefs

Programs

  • Python
    from math import log, ceil
    def A350588(n):
        if n <= 8:
            b, S = 10**n, set()
            for i in range(b):
                t, s, T = i, 0, set()
                while t not in T: T.add(t); t = (t**5)%b; s += 1
                S.add(s)
            return(len(S))
        else: return n*n - 3*n - 17 - sum(ceil(log(i, 2)) for i in range(9, n+1))

Formula

For n >= 9, a(n) = a(n-1) + 2*n - 4 - ceiling(log_2 (n)) or a(n) = n^2 - 3*n - 17 - Sum_{i=9..n} ceiling(log_2 (i)).
Showing 1-4 of 4 results.