cp's OEIS Frontend

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.

A291654 Number of distinct values in the prime tree starting with n.

Original entry on oeis.org

35, 35, 34, 22, 12, 11, 5, 7, 10, 5, 10, 10, 6, 6, 7, 7, 4, 3, 5, 13, 14, 6, 1, 5, 5, 3, 4, 3, 2, 2, 4, 3, 2, 2, 3, 3, 1, 4, 6, 3, 3, 3, 1, 3, 7, 6, 2, 2, 2, 6, 6, 1, 6, 9, 5, 5, 5, 2, 4, 5, 2, 2, 2, 7, 8, 7, 6, 2, 3, 4, 5, 3, 1, 1, 4, 5, 4, 4
Offset: 1

Views

Author

Ralf Steiner and Sean A. Irvine, Aug 28 2017

Keywords

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.

Examples

			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-|
		

Programs

  • 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 *)