OFFSET
1,1
LINKS
Paolo Xausa, Table of n, a(n) for n = 1..1000
Wikipedia, Multiplicative order
Index entries for linear recurrences with constant coefficients, signature (6,-5,1,-6,5).
EXAMPLE
For n = 1, we begin with 1, iteratively multiply by 8 and count the number of terms before the last 1 digit begins to repeat. We obtain 1, 8, 64, 512, 4096, ... . The next term is 32768, which repeats the last 1 digit 8. Thus, the number of distinct terms is a(1) = 5.
MATHEMATICA
A362556[n_]:=5^(n-1)4+Ceiling[n/3]; Array[A362556, 30] (* after Charles R Greathouse IV *) (* or *) LinearRecurrence[{6, -5, 1, -6, 5}, {5, 21, 101, 502, 2502}, 30] (* Paolo Xausa, Nov 18 2023 *)
PROG
(Python)
def a(n):
s, x, M = set(), 1, 10**n
while x not in s: s.add(x); x = (x<<3)%M
return len(s)
(PARI) a(n)=4*5^(n-1)+ceil(n/3) \\ Charles R Greathouse IV, Apr 28 2023
CROSSREFS
KEYWORD
nonn,base,easy
AUTHOR
Gil Moses, Apr 24 2023
EXTENSIONS
a(13)-a(21) from Charles R Greathouse IV, Apr 28 2023
STATUS
approved