cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A380816 Number of pairs (x, y) with 0 < x < y < n such that x^y = y^x modulo n.

This page as a plain text file.
%I A380816 #25 Mar 17 2025 11:31:01
%S A380816 0,0,0,0,1,1,5,2,2,3,5,6,8,8,6,18,11,7,20,16,15,17,28,28,15,23,32,27,
%T A380816 24,22,35,88,20,31,19,34,32,43,35,72,33,40,37,52,45,51,57,134,36,37,
%U A380816 38,73,65,73,61,118,72,52,59,94,61,74,111,428,67,65,69
%N A380816 Number of pairs (x, y) with 0 < x < y < n such that x^y = y^x modulo n.
%H A380816 Paolo Xausa, <a href="/A380816/b380816.txt">Table of n, a(n) for n = 1..1000</a>
%e A380816 For n < 5 there are no (x, y) with 0 < x < y < n such that x^y = y^x modulo n. Therefore a(n) = 0.
%e A380816 For n = 5 and 6 there is only 2^4 = 4^2 modulo n which makes a(5) = a(6) = 1.
%e A380816 For n = 7, there is 2^4=4^2, 2^5=5^2, 2^6=6^2, 4^5=5^4 and 4^6=6^4 modulo 7 which makes a(7) = 5.
%t A380816 A380816[n_] := Sum[Boole[PowerMod[x, y, n] == PowerMod[y, x, n]], {x, 2, n-2}, {y, x+1, n-1}];
%t A380816 Array[A380816, 100] (* _Paolo Xausa_, Mar 17 2025 *)
%o A380816 (PARI) a(n)={my(c=0);for(x=1,n-1,for(y=x+1,n-1,if(Mod(x,n)^y==Mod(y,n)^x,c++)));c}
%o A380816 (Python)
%o A380816 def A380816(n): return sum(1 for x in range(1,n-1) for y in range(x+1,n) if pow(x,y,n)==pow(y,x,n)) # _Chai Wah Wu_, Feb 12 2025
%K A380816 nonn,nice
%O A380816 1,7
%A A380816 _Peter Schorn_, Feb 04 2025