OFFSET
1,1
COMMENTS
a(n) is always greater than n.
LINKS
Project Euler, Problem 801: x^y == y^x, (2022)
FORMULA
a(n) = Sum_{x=0..n} Sum_{y=0..n} [x^y == y^x (mod n)].
PROG
(Python)
def a(n):
count = 0
for x in range(0, n + 1):
for y in range(0, n + 1):
if x == y or pow(x, y, n) == pow(y, x, n): count += 1
return count
(PARI) a(n) = sum(x=0, n, sum(y=0, n, Mod(x, n)^y == Mod(y, n)^x)); \\ Michel Marcus, Jan 16 2023
CROSSREFS
KEYWORD
nonn
AUTHOR
Darío Clavijo, Jan 16 2023
STATUS
approved