login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

Numbers k such that prime(k) divides k^k - 1.
2

%I #20 Sep 30 2024 14:11:51

%S 1,2,5,124,181,696,261800,3834909,18836480,51432542,69709961,

%T 332054520,3140421767

%N Numbers k such that prime(k) divides k^k - 1.

%C a(14) > 10^12. - _Giovanni Resta_, May 11 2020

%t Select[Range[10^6], PowerMod[#, #, Prime@#] == 1 &] (* _Giovanni Resta_, May 23 2013 *)

%o (Python)

%o primes = []

%o n = 0

%o def addPrime(k):

%o global n

%o for p in primes:

%o if k%p==0: return

%o if p*p > k: break

%o primes.append(k)

%o n += 1

%o if (n**n-1) % k == 0: print(n, end=", ")

%o addPrime(2)

%o addPrime(3)

%o for i in range(5, 10000000, 6):

%o addPrime(i)

%o addPrime(i+2)

%o (Python)

%o from sympy import nextprime, prime

%o from itertools import count, islice

%o def agen(startn=1): # generator of terms

%o pn = prime(startn)

%o for n in count(startn):

%o if pow(n, n, pn) == 1:

%o yield n

%o pn = nextprime(pn)

%o print(list(islice(agen(), 7))) # _Michael S. Branicky_, May 25 2023

%Y Cf. A000040, A000312, A048861, A225945.

%K nonn,more

%O 1,2

%A _Alex Ratushnyak_, May 21 2013

%E a(8)-a(13) from _Giovanni Resta_, May 23 2013