login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

A352962
a(1) = 2, a(n) = Min(n,a(n-1)) if gcd(n,a(n-1)) = 1, else a(n) = n + 2.
0
2, 4, 3, 3, 3, 8, 7, 7, 7, 7, 7, 7, 7, 16, 15, 15, 15, 20, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 40, 39, 39, 39, 44, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43
OFFSET
1,1
EXAMPLE
a(1) = 2, gcd(2,2) = 2 thus a(2) = 4
a(2) = 4, gcd(3,4) = 1 thus a(3) = Min(3,4) = 3
a(3) = 3, gcd(4,3) = 1 thus a(4) = Min(4,3) = 3, etc.
MATHEMATICA
a[1] = 2; a[n_] := a[n] = If[CoprimeQ[n, a[n - 1]], Min[n, a[n - 1]], n + 2]; Array[a, 100] (* Amiram Eldar, Apr 11 2022 *)
PROG
(Python)
from math import gcd
from itertools import count, islice
def A352962_gen(): # generator of terms
a = 2
yield a
for n in count(2):
yield (a:= min(n, a) if gcd(n, a) == 1 else n+2)
A352962_list = list(islice(A352962_gen(), 30)) # Chai Wah Wu, May 24 2022
CROSSREFS
Sequence in context: A220080 A343766 A299920 * A137363 A110549 A378814
KEYWORD
nonn
AUTHOR
Ctibor O. Zizka, Apr 11 2022
STATUS
approved