This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.
%I A371024 #30 Dec 21 2024 07:48:01 %S A371024 2,3,29,5,23,269,272879,149,61463,929,7426253,2609,233,59, %T A371024 78977932125503 %N A371024 a(n) is the least prime p such that p + 4*k*(k+1) is prime for 0 <= k <= n-1 but not for k=n. %C A371024 a(15) > 3277860277, a(16) > 3103623446, a(17) > 2853255995, %C A371024 a(18) = 653, a(19) > 2480173428, a(20) > 2058783580, a(21) > 1894529774, a(22) > 1896261075, a(23) > 1836831342, a(24), ..., a(100) > 15000000. %C A371024 Other than a(1)-a(14) and a(18), no terms < 24870000007. - _Michael S. Branicky_, Apr 12 2024 %C A371024 From _David A. Corneth_, Apr 12 2024: (Start) %C A371024 Using remainders mod q we can restrict the search. For example for a(15) a term can only be 2, 3 or 5 (mod 7). Or maybe 7 itself. If a(15) = p == 1 (mod 7) then for k = 3 we have q + 4*3*(3+1) == 0 mod 7. Similarily number 0, 4 and 6 (mod 7) produce a multiple of 7 where they should not. %C A371024 Doing so for various primes mod q we can reduce the number of remainders and with that the search space by combining the possible remainders using the Chinese Remainder Theorem (CRT). %C A371024 So the possible remainders mod 2 are 1. The possible remainders mod 3 are 2. Using the CRT, a number of the form 1 (mod 2) and 2 (mod 3) simultaneously is of the form 5 (mod 6). %C A371024 a(15) > 2.3*10^13 if it exists. (End) %p A371024 f:= proc(p) local k; %p A371024 for k from 1 while isprime(p+k*(k+1)*4) do od: %p A371024 k %p A371024 end proc: %p A371024 A:= Vector(12): count:= 0: %p A371024 for i from 1 while count < 12 do %p A371024 v:= f(ithprime(i)); %p A371024 if A[v] = 0 then count:= count+1; A[v]:= ithprime(i) fi %p A371024 od: %p A371024 convert(A,list); %t A371024 Table[p=1;m=4;Monitor[Parallelize[While[True,If[And[MemberQ[PrimeQ[Table[p+m*k*(k+1),{k,0,n-1}]],False]==False,PrimeQ[p+m*n*(n+1)]==False],Break[]];p++];p],p],{n,1,10}] %o A371024 (PARI) isok(p, n) = for (k=0, n-1, if (! isprime(p + 4*k*(k+1)), return(0))); return (!isprime(p + 4*n*(n+1))); %o A371024 a(n) = my(p=2); while (!isok(p, n), p=nextprime(p+1)); p; \\ _Michel Marcus_, Mar 12 2024 %o A371024 (Python) %o A371024 from sympy import isprime, nextprime %o A371024 from itertools import count, islice %o A371024 def f(p): %o A371024 k = 1 %o A371024 while isprime(p+4*k*(k+1)): k += 1 %o A371024 return k %o A371024 def agen(verbose=False): # generator of terms %o A371024 adict, n, p = dict(), 1, 1 %o A371024 while True: %o A371024 p = nextprime(p) %o A371024 v = f(p) %o A371024 if v not in adict: %o A371024 adict[v] = p %o A371024 if verbose: print("FOUND", v, p) %o A371024 while n in adict: %o A371024 yield adict[n]; n += 1 %o A371024 print(list(islice(agen(), 14))) # _Michael S. Branicky_, Apr 12 2024 %o A371024 (Perl) use ntheory qw(:all); sub a { my $n = $_[0]; my $lo = 2; my $hi = 2*$lo; while (1) { my @terms = grep { !is_prime($_ + 4*$n*($n+1)) } sieve_prime_cluster($lo, $hi, map { 4*$_*($_+1) } 1 .. $n-1); return $terms[0] if @terms; $lo = $hi+1; $hi = 2*$lo; } }; $| = 1; for my $n (1..100) { print a($n), ", " }; # _Daniel Suteu_, Dec 17 2024 %Y A371024 Cf. A164926, A370387. %K A371024 nonn,more %O A371024 1,1 %A A371024 _J.W.L. (Jan) Eerland_, Mar 08 2024 %E A371024 a(15) from _Daniel Suteu_, Dec 17 2024