OFFSET
1,2
LINKS
Michael De Vlieger, Scatterplot of a(n), for n=1..2^16, accentuating smaller terms for clarity, labeling a(n) for n=1..32.
EXAMPLE
a(1) = 1 by definition; as 1 has no available divisor yet present in the sequence, we produce a(2) = 2*1 + 1 = 3.
a(2) = 3; as 3 has no available divisor yet present in the sequence, we produce a(3) = 2*3 + 1 = 7;
a(3) = 7; 7 has no available divisor yet present in the sequence, we produce a(4) = 2*7 + 1 = 15;
a(4) = 15; as 15 has 5 as its smallest divisor not yet present in the sequence, we have a(5) = 5.
MATHEMATICA
a[1]=1; a[n_]:=a[n]=If[(s=Complement[Rest@Divisors@a[n-1], Array[a, n-1]])!={}, Min@s, 2a[n-1]+1]; Array[a, 73] (* Giorgos Kalogeropoulos, Nov 02 2021 *)
(* Second program generates a million terms in less than a minute: *)
c[_] = 0; c[1] = m = 1; {1}~Join~Reap[Do[Set[n, If[MissingQ[#], 2 m + 1, #]] &@ SelectFirst[Divisors[m], c[#] == 0 &]; c[n]++; Sow[n]; m = n, {i, 2^20}]][[-1, -1]]] (* Michael De Vlieger, Nov 05 2021 *)
PROG
(Python)
from sympy import divisors
terms = [1]
for i in range(100):
for j in divisors(terms[-1]):
if j not in terms:
terms.append(j)
break
else:
terms.append(terms[-1]*2+1)
print(terms) # Gleb Ivanov, Nov 09 2021
CROSSREFS
KEYWORD
base,nonn
AUTHOR
Eric Angelini and Carole Dubois, Nov 02 2021
STATUS
approved