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