OFFSET
0,2
COMMENTS
If 2n+1 is 1 or a prime, set a(n) = 2n+1. If no prime is ever reached, set a(n) = -1.
EXAMPLE
n = 7: 2n+1 = 15 = 3*5 -> 35 = 5*7 -> 57 = 3*19 -> 319 = 11*29 -> 1129, prime, so a(7) = 1129.
PROG
(Python)
from sympy import divisors, isprime
def f(n): return int("".join(str(d) for d in divisors(n)[1:-1]))
def a(n):
if n == 0: return 1
fn, c = 2*n + 1, 0
while not isprime(fn):
fn, c = f(fn), c+1
return fn
print([a(n) for n in range(22)]) # Michael S. Branicky, Jul 11 2022
CROSSREFS
KEYWORD
nonn,base,more
AUTHOR
N. J. A. Sloane, Jul 30 2007
EXTENSIONS
Name edited by Michel Marcus, Mar 09 2023
STATUS
approved