OFFSET
1,2
COMMENTS
If k = 3*j+1 is prime and 2^j - 1 is not divisible by k, then k is a term, as 1 + 2^j + 4^j = (2^(k-1)-1)/(2^j - 1) == 0 (mod k). - Robert Israel, Aug 06 2023
LINKS
Robert Israel, Table of n, a(n) for n = 1..10000
EXAMPLE
a(4) = 13 is a term because 1 + 2^4 + 4^4 = 273 = 21 * 13 is divisible by 13.
MAPLE
filter:= proc(n) local x, r;
for r in map(t -> subs(t, x), [msolve(1+x+x^2, n)]) do
try
NumberTheory:-ModularLog(r, 2, n);
catch "no solutions exist": next
end try;
return true
od;
false
end proc:
select(filter, [seq(i, i=1..1000, 2)]);
PROG
(Python)
from itertools import count, islice
from sympy import sqrt_mod_iter, discrete_log
def A364722_gen(startvalue=1): # generator of terms >= startvalue
if startvalue <= 1:
yield 1
if startvalue <= 3:
yield 3
for k in count(max(startvalue, 4)):
for d in (r>>1 for r in sqrt_mod_iter(-3, k) if r&1):
try:
discrete_log(k, d, 2)
except:
continue
yield k
break
CROSSREFS
KEYWORD
nonn
AUTHOR
Robert Israel, Aug 04 2023
STATUS
approved