OFFSET
1,2
LINKS
Robert Israel, Table of n, a(n) for n = 1..10000
FORMULA
a(2^k) = (2*k-1)*2^(k-1) for k >= 1.
If n possesses a primitive root (i.e., n is in A033948), then a(n) = Sum_{k=1..n} gcd(phi(n),k), where phi is Euler's totient function A000010.
From Ridouane Oudra, May 28 2026: (Start)
a(n) = Sum_{1<=k<=n, gcd(n,k)=1} floor(n/order(k,n)).
If n is in A033948 then:
a(n) = Sum_{d|lambda(n)} phi(d)*floor(n/d), or also: a(n) = Sum_{d|phi(n)} phi(d)*floor(n/d).
In particular, a(p) = Sum_{d|(p-1)} phi(d)*floor(p/d), for p prime. (End)
EXAMPLE
a(3) = 4 because there are 4 solutions to x^y == 1 (mod 3): 1^1 == 1 (3), 1^2 == 1 (3), 1^3 == 1 (3), 2^2 == 1 (3).
MAPLE
f:= proc(n) local t, x, r;
t:= 0;
for x from 1 to n-1 do if igcd(n, x) = 1 then
r:= numtheory:-order(x, n);
t:= t + floor(n/r)
fi od;
t
end proc:
f(1):= 1:
map(f, [$1..100]): # Robert Israel, Mar 25 2020
MATHEMATICA
a[n_] := If[n == 1, 1, Sum[Boole[PowerMod[x, y, n] == 1], {x, 0, n - 1}, {y, 1, n}]];
Array[a, 100] (* Jean-François Alcover, Jun 08 2020 *)
PROG
(PARI) a(n) = sum(x=0, n-1, sum (y=1, n, Mod(x, n)^y == 1)); \\ Michel Marcus, Mar 20 2020
CROSSREFS
KEYWORD
nonn
AUTHOR
Franz Vrabec, Mar 18 2020
EXTENSIONS
More terms from Hugo Pfoertner, Mar 22 2020
STATUS
approved
