OFFSET
1,2
LINKS
T. D. Noe, Table of n, a(n) for n = 1..10000
FORMULA
a(n) = Sum_{d|m} phi(d)/ord(9, d), where m is n with all factors of 3 removed. - T. D. Noe, Apr 21 2003
a(n) = (1/ord(9,m))*Sum_{j = 0..ord(9,m)-1} gcd(9^j - 1, m), where m is n with all factors of 3 removed. - Nihar Prakash Gargava, Nov 14 2018
EXAMPLE
a(12) = 4 because the function 9x mod 12 has the four cycles (0),(3),(1,9),(2,6).
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[9, n], {n, 100}]
PROG
(Python)
from sympy import totient, n_order, divisors
def A023141(n):
a, b = divmod(n, 3)
while not b:
n = a
a, b = divmod(n, 3)
return sum(totient(d)//n_order(9, d) for d in divisors(n, generator=True) if d>1)+1 # Chai Wah Wu, Apr 09 2024
CROSSREFS
KEYWORD
nonn
AUTHOR
STATUS
approved