%I #26 Jan 11 2020 15:57:47
%S 1,4,16,27,256,3125,46656,823543,16777216,387420489,10000000000,
%T 285311670611,8916100448256,302875106592253,11112006825558016,
%U 437893890380859375,18446744073709551616,827240261886336764177,39346408075296537575424,1978419655660313589123979,104857600000000000000000000
%N Commutative powers: numbers of the form a^b = b^a.
%C The only integer solutions (a,b) to the equation a^b = b^a are (k,k) for k >= 0, (2,4), and (4,2). [Corrected by _M. F. Hasler_, Oct 15 2019]
%C Suppose a < b. If a^b = b^a, log(a^b) = log(b^a) so log(a)/a = log(b)/b.
%C Now f(x) = log(x)/x is strictly increasing at (0,e) and strictly decreasing at (e, +infinity), so if 0 < x < y < e or e < y < x then f(x) < f(y).
%C To have f(a) = f(b) (which means a^b = b^a), a must be in (0,e) and b in (e, +infinity). Let g(a) be the restriction of f to (0,e) and h(b) to (e, +infinity). Since g and h are monotonic, there is a natural bijection between a and b such that g(a) = h(b).
%C In (0,e) there are two integers: 1 and 2.
%C 1 won't work since there are no solutions 1^b=b^1 for b>e.
%C 2 will because 2^4 = 4^2 and since we have a bijection this is the only solution.
%C This is the range of A000312(n) = n^n together with { 16 }. - _M. F. Hasler_, Oct 15 2019
%F a(n) = A000302(n-1) = 4^(n-1) for 1 <= n <= 3;
%F a(n) = A000312(n-1) = (n-1)^(n-1) for all n >= 4.
%e 4 is in the list because 2^2 = 2^2;
%e 16 is in the list because 2^4 = 4^2. This is the only term not of the form n^n.
%t Union[Power @@@ Select[Tuples[Range@ 20, 2], Power @@ # == Power @@ Reverse@ # &]] (* _Michael De Vlieger_, Apr 17 2016 *)
%o (PARI) a(n)=if(n>3,n-1,4)^(n-1) \\ _M. F. Hasler_, Oct 15 2019
%Y Cf. A000312.
%K nonn,easy
%O 1,2
%A _Natan Arie Consigli_, Apr 16 2016
%E Edited by _M. F. Hasler_, Oct 15 2019