OFFSET
1,3
LINKS
T. D. Noe, Table of n, a(n) for n = 1..10000
FORMULA
a(n) = Sum_{d|m} phi(d)/ord(10, d), where m is n with all factors of 2 and 5 removed. - T. D. Noe, Apr 21 2003
EXAMPLE
a(12) = 3 because the function 10x mod 12 has the three cycles (0),(1,10,4),(2,8).
MATHEMATICA
CountFactors[p_, n_] := Module[{sum=0, m=n, d, f, i, ps, j}, ps=Transpose[FactorInteger[p]][[1]]; Do[While[Mod[m, ps[[j]]]==0, m/=ps[[j]]], {j, Length[ps]}]; d=Divisors[m]; Do[f=d[[i]]; sum+=EulerPhi[f]/MultiplicativeOrder[p, f], {i, Length[d]}]; sum]; Table[CountFactors[10, n], {n, 100}]
PROG
(PARI) a(n)=n/=2^valuation(n, 2)*5^valuation(n, 5); sumdiv(n, d, eulerphi(d)/znorder(Mod(10, d))) \\ Charles R Greathouse IV, Apr 24 2013
(Python)
from sympy import totient, n_order, divisors
def A023142(n):
m = n>>(~n & n-1).bit_length()
a, b = divmod(m, 5)
while not b:
m = a
a, b = divmod(m, 5)
return sum(totient(d)//n_order(10, d) for d in divisors(m, generator=True) if d>1)+1 # Chai Wah Wu, Apr 09 2024
CROSSREFS
KEYWORD
nonn
AUTHOR
STATUS
approved