login
Smallest prime number p such that x^n + y^n mod p does not take all values on Z/pZ.
4

%I #22 Nov 28 2023 11:00:40

%S 7,5,11,7,29,5,7,11,23,5,53,29,7,5,103,7,191,5,7,23,47,5,11,53,7,5,59,

%T 7,311,5,7,103,11,5,149,191,7,5,83,7,173,5,7,47,283,5,29,11,7,5,107,7,

%U 11,5,7,59,709,5,367,311,7,5,11,7,269,5,7,11,569,5,293,149,7,5,23,7,317,5

%N Smallest prime number p such that x^n + y^n mod p does not take all values on Z/pZ.

%C If there exists some prime p > 3 such that p-1 divides n, then x^n (mod p) is either 0 or 1 for all integers x, therefore giving an upper bound of a(n) <= p.

%H Robin Visser, <a href="/A367689/b367689.txt">Table of n, a(n) for n = 3..5000</a>

%e For n = 3, x^3 + y^3 attains all values on Z/2Z, Z/3Z, and Z/5Z, but x^3 + y^3 == 3 (mod 7) has no solution, so a(3) = 7.

%e For n = 4, x^4 + y^4 attains all values on Z/2Z and Z/3Z, but x^4 + y^4 == 3 (mod 5) has no solution, so a(4) = 5.

%o (Sage)

%o def a(n):

%o for p in Primes():

%o all_values = set()

%o for x in range(p):

%o for y in range(p):

%o all_values.add((x^n+y^n)%p)

%o if len(all_values) < p: return p

%o (PARI) a(n) = my(p=2); while (#setbinop((x,y)->Mod(x,p)^n+Mod(y,p)^n, [0..p-1]) == p, p=nextprime(p+1)); p; \\ _Michel Marcus_, Nov 27 2023

%o (Python)

%o from itertools import combinations_with_replacement

%o from sympy import sieve

%o def A367689(n):

%o for p in sieve.primerange(n**4+1):

%o s = set()

%o for k in combinations_with_replacement({pow(x,n,p) for x in range(p)},2):

%o s.add(sum(k)%p)

%o if len(s) == p:

%o break

%o else:

%o return p # _Chai Wah Wu_, Nov 27 2023

%Y Cf. A355920, A367688.

%K nonn

%O 3,1

%A _Robin Visser_, Nov 26 2023