%I #12 May 02 2024 14:29:33
%S 0,0,1,4,6,2,12,4,7,6,20,22,3,13,4,16,17,12,12,46,14,5,54,52,60,20,32,
%T 33,22,70,6,26,8,45,4,16,34,34,52,12,10,7,49,116,114,61,124,126,68,46,
%U 140,20,24,10,77,22,81,54,52,174,180,60,182,13,38,48,32,66,101,204,206,15,70,28,220
%N a(n) is the least k such that 1^k + 2^k + 4^k is divisible by A364722(n).
%C a(n) is the least k such that 1^k + 2^k + 4^k is divisible by the n-th number for which such k exists.
%H Robert Israel, <a href="/A364724/b364724.txt">Table of n, a(n) for n = 1..10000</a>
%e a(4) = 4 because A364722(4) = 13 and 1 + 2^4 + 4^4 = 273 = 21 * 13 is divisible by 13.
%p f:= proc(n) local R,r,m,v;
%p R:= map(t -> subs(t,x), [msolve(1+x+x^2, n)]);
%p m:= infinity;
%p for r in R do
%p try
%p v:= NumberTheory:-ModularLog(r,2,n);
%p catch "no solutions exist": next
%p end try;
%p m:= min(m,v)
%p od;
%p subs(infinity=NULL,m);
%p end proc:
%p map(f, [seq(i,i=1..1000,2)]);
%o (Python)
%o from itertools import count, islice
%o from sympy import sqrt_mod_iter, discrete_log
%o def A364724_gen(): # generator of terms
%o yield 0
%o for k in count(2):
%o m = None
%o for d in sqrt_mod_iter(-3,k):
%o r = d>>1 if d&1 else d+k>>1
%o try:
%o m = discrete_log(k,r,2) if m is None else min(m,discrete_log(k,r,2))
%o except:
%o continue
%o if m is not None: yield m
%o A364724_list = list(islice(A364724_gen(),30))
%Y Cf. A001576, A364722.
%K nonn,look
%O 1,4
%A _Robert Israel_, Aug 04 2023