%I #58 Oct 30 2023 09:20:23
%S 2,3,5,7,13,17,19,31,61,89,107,127,257,521,607,1279,2203,2281,3217,
%T 4253,4423,9689,9941,11213,19937,21701,23209,44497,65537
%N Numbers k > 1 such that (k-1)^(2^k-2) == 1 (mod (2^k-1)*k^2).
%C Conjecture: for k > 1, (2^k-1)*k^2 divides (k-1)^(2^k-2)-1 if and only if 2^k-1 is (a Mersenne) prime or k = 2^(2^m)+1 (is a Fermat number).
%C If so, composite terms are Fermat composite numbers k = 2^(2^m)+1. The smallest (for m = 5) is k = 4294967297 = 641*6700417 and probably all larger (for m > 5).
%C If my conjecture is true, primes in this sequence that are not Mersenne exponents are Fermat prime numbers k = 2^(2^m)+1 for m > 2, namely k = 257, 65537 and there are probably no more.
%t q[n_] := PowerMod[n - 1, 2^n - 2, n^2*(2^n - 1)] == 1; Select[Range[1000], q] (* _Amiram Eldar_, Oct 02 2023 *)
%o (Python)
%o def A366029_gen(startvalue=1): # generator of terms>= startvalue
%o return filter(lambda k:pow(k-1,(m:=(1<<k)-1)-1,m*k**2)==1,count(max(startvalue,1)))
%o A366029_list = list(islice(A366029_gen(),10)) # _Chai Wah Wu_, Oct 30 2023
%Y Cf. A000043, A000215.
%K nonn,more,hard
%O 1,1
%A _Thomas Ordowski_, Oct 01 2023
%E More terms from _Amiram Eldar_, Oct 02 2023