OFFSET
1,1
LINKS
Michael S. Branicky, Table of n, a(n) for n = 1..2600
MAPLE
MATHEMATICA
f[n_] := Mod[4*((n - 1)! + 1) + n, n*(n + 2)];
pp = Select[Prime[Range[300]], PrimeQ[# + 2] & ];
a[n_] := MaximalBy[Range[pp[[n]], pp[[n + 1]]], f];
Array[a, Length[pp] - 1] // Flatten (* Jean-François Alcover, Feb 22 2018 *)
PROG
(Python)
from math import factorial
from itertools import islice, pairwise
from sympy import isprime, nextprime, primerange
def f(n): return (4*(factorial(n-1) + 1) + n)%(n*(n + 2))
def bgen(): # generator of A001359
p, q = 2, 3
while True:
if q - p == 2: yield p
p, q = q, nextprime(q)
def agen(): # generator of terms
for p, q in pairwise(bgen()):
yield max((f(k), k) for k in range(p+1, q))[1]
print(list(islice(agen(), 80))) # Michael S. Branicky, Aug 13 2024
CROSSREFS
KEYWORD
nonn
AUTHOR
Reinhard Zumkeller, Aug 12 2002
STATUS
approved