OFFSET
1,1
COMMENTS
Note all prime trees have a minimum depth of 1, as the starting prime forms the root of the tree.
LINKS
Alois P. Heinz, Table of n, a(n) for n = 1..65536
EXAMPLE
a(125) = 5 because the 125th prime is 691, which generates further primes through 4 repeated applications of 4p +- 3, giving a prime tree with generations as follows:
1. 691
2. 4 * 691 + 3 = 2767
3. 4 * 2767 + 3 = 11071
4. 4 * 11071 - 3 = 44281
5. 4 * 44281 + 3 = 177127
MAPLE
b:= proc(p) option remember;
`if`(isprime(p), 1 + max(b(4*p+3), b(4*p-3)), 0)
end:
a:= n-> b(ithprime(n)):
seq(a(n), n=1..120); # Alois P. Heinz, Dec 02 2018
MATHEMATICA
f[n_] := f[n] = If[PrimeQ[n], 1 + Max[f[4 n - 3], f[4 n + 3]], 0]; f /@ Prime@Range@100 (* Amiram Eldar, Dec 02 2018 *)
PROG
(Python)
from functools import cache
from sympy import isprime, prime
@cache
def b(p): return 1 + max(b(4*p+3), b(4*p-3)) if isprime(p) else 0
def a(n): return b(prime(n))
print([a(n) for n in range(1, 105)]) # Michael S. Branicky, Nov 01 2021 after Alois P. Heinz
CROSSREFS
KEYWORD
nonn
AUTHOR
Chuck Seggelin (barkeep(AT)plastereddragon.com), Jul 17 2003
EXTENSIONS
Offset corrected by Alois P. Heinz, Dec 02 2018
STATUS
approved