%I #9 Jun 22 2026 21:19:51
%S 27,216,243,343,1331,1728,2187,2744,3375,6859,7776,9261,10648,12167,
%T 13824,16807,19683,21952,27000,29791,35937,42875,54872,59319,74088,
%U 79507,85184,97336,103823,110592,132651,157464,161051,166375,175616,177147,185193,205379,216000
%N Perfect powers not representable as sums of two squares.
%C Perfect powers m^k with odd k >= 3 such that m is not representable as a sum of two squares.
%C By Fermat's theorem on sums of two squares, this holds iff m contains a prime congruent to 3 mod 4 (A002145) with odd exponent.
%C Equivalently, these are perfect powers m^k with odd exponent k such that m is in A022544.
%C No squares occur in this sequence.
%C This sequence generalizes A125111, which corresponds to the case k = 3.
%H Felix Huber, <a href="/A396778/b396778.txt">Table of n, a(n) for n = 1..10000</a>
%H Wikipedia, <a href="https://en.wikipedia.org/wiki/Fermat%27s_theorem_on_sums_of_two_squares">Fermat's theorem on sums of two squares</a>.
%F a(n) are the numbers m^k with k >= 3 odd such that m is in A022544.
%e 216 = 6^3 is a term, since 6 contains the prime 3 == 3 (mod 4) to odd exponent; hence 216 is not representable as a sum of two squares.
%e 16807 = 7^5 is a term, since 7 is congruent to 3 mod 4 and occurs to odd exponent; hence 16807 is not representable as a sum of two squares.
%p A396778List := proc(N)
%p local b, l, p, k, m, r, t;
%p b := table(); l := floor(N^(1/3));
%p for m from 2 to l do b[m] := false end do;
%p for p from 3 to l do
%p if isprime(p) and p mod 4 = 3 then
%p for k from 1 to floor(log(l)/log(p)) do
%p if k mod 2 = 1 then
%p for m from p^k to l by p^k do
%p if irem(m, p^(k + 1)) <> 0 then b[m] := true end if
%p end do
%p end if
%p end do
%p end if
%p end do;
%p t := table();
%p for m from 2 to l do
%p if b[m] then
%p r := m^3;
%p while r <= N do
%p t[r] := true; r := r*m^2
%p end do
%p end if
%p end do;
%p return sort([indices(t, 'nolist')])
%p end proc:
%p A396778List(216000);
%t With[{nn = 2^18}, Union@ Flatten[Table[If[SquaresR[2, #] == 0, #, Nothing] &[k^m], {m, 2, Log2[nn]}, {k, 2, Surd[nn, m]} ] ] ] (* _Michael De Vlieger_, Jun 18 2026 *)
%Y Subsequence of A001597.
%Y Supersequence of A125111.
%Y Disjoint from A000290.
%Y Cf. A001481, A002145, A022544.
%K nonn,easy,new
%O 1,1
%A _Felix Huber_, Jun 18 2026