%I #14 May 02 2024 17:33:52
%S 1,18,18,1047,1353,34967,82681,2387947,14906455,135967276,700917774,
%T 4655571260,18496858461,272170172759,950393245608,10445516265494,
%U 43678446835095,654213095126525,654213095126525,22143577275619760,101935843573231761,1777573435823083782,6042068661342892315
%N a(n) is the least k such that k^2 + k + 1 is divisible by the n-th power of a prime.
%C For n > 1 the prime is in A002476. Conjecture: it is always 7.
%H Robert Israel, <a href="/A372457/b372457.txt">Table of n, a(n) for n = 1..1182</a>
%e a(4) = 1047 because 1047^2 + 1047 + 1 = 1097257 is divisible by 7^4.
%p g:= proc(n) local p,t,tm,r,s,S;
%p tm:= infinity; r:= infinity;
%p for p from 7 by 6 do
%p if p^n > r then return tm fi;
%p if not isprime(p) then next fi;
%p S:= [msolve(t^2+t+1,p^n)];
%p if S = [] then next fi;
%p s:= min(map(rhs@op,S));
%p if s < tm then tm:= s; r:= s^2 + s + 1 fi;
%p od;
%p end proc:
%p g(1):= 1:
%p map(g, [$1..30]);
%o (Python)
%o from sympy import sqrt_mod_iter, nextprime
%o def A372457(n):
%o if n == 1: return 1
%o p, m, r = 7, None, None
%o while (m is None or p**n <= m):
%o if (k:=min((r>>1 for r in sqrt_mod_iter(-3,p**n) if r&1),default=None)) is not None:
%o m = (r:=k if r is None else min(r,k))*(r+1)+1
%o while (p:=nextprime(p))%6!=1: pass
%o return r # _Chai Wah Wu_, May 02 2024
%Y Cf. A002476.
%K nonn
%O 1,2
%A _Robert Israel_, May 01 2024
|