OFFSET
1,1
COMMENTS
Starting from n construct a tree that includes nodes for each prime in n^2 + n + 1, n^2 + n - 1, n^2 - n + 1, n^2 - n - 1, and recurse on each node until no further primes can be included.
LINKS
Robert Israel, Table of n, a(n) for n = 1..10000
Ralf Steiner, Prime-trees, NMBRTHRY posting, 13 Aug 2017.
EXAMPLE
a(5) = 12 since the tree for 5 looks like this where, for example, the symbol -[+-]-> stands for p^2+p-1 and the symbol -| stands for a leaf:
5-[--]->19-[+-]->379-[--]->143261-|
-[-+]->143263-[-+]->20524143907-|
-[+-]->29-[--]->811-|
-[++]->31-[--]->929-|
-[+-]->991-[-+]->981091-|
MAPLE
f:= proc(n) local R, agenda;
agenda:= {n}; R:= {n};
while nops(agenda) > 0 do
agenda:= select(isprime, map(t -> (t^2+t+1, t^2+t-1, t^2-t+1, t^2-t-1), agenda) minus R) ;
R:= R union agenda;
od;
nops(R);
end proc:
map(f, [$1..100]); # Robert Israel, Aug 29 2017
MATHEMATICA
f[n_] := Module[{R = {n}, agenda = {n}}, While[Length[agenda] > 0, agenda = Select[Flatten[Map[Function[t, {t^2 + t + 1, t^2 + t - 1, t^2 - t + 1, t^2 - t - 1}], agenda]] ~Complement~ R, PrimeQ]; R = Union[R, agenda]]; Length[R]];
Array[f, 100] (* Jean-François Alcover, Jul 30 2020, after Robert Israel *)
CROSSREFS
KEYWORD
nonn
AUTHOR
Ralf Steiner and Sean A. Irvine, Aug 28 2017
STATUS
approved