OFFSET
1,2
LINKS
Michael De Vlieger, Log log scatterplot of a(n), n = 1..2^20.
Michael De Vlieger, Log log scatterplot of a(n), n = 1..2^16, with x = gcd(a(n-1), n), showing x=1 or a(n-1)/x = 1 in red, else dark blue.
EXAMPLE
For n=2, gcd(2,1)=1 so a(2) = 2+1 = 3.
For n=3, gcd(3,3)=3=a(2) so a(3) = 3+3 = 6.
For n=4, gcd(4,6)=2 so a(4) = 6/2 = 3.
MATHEMATICA
nn = 2^16; a[1] = 1; Do[g = GCD[a[n - 1], n]; If[Or[g == 1, Set[k, a[n - 1]/g] == 1], a[n] = a[n - 1] + n, a[n] = k], {n, 2, nn}]; Array[a, nn] (* Michael De Vlieger, Dec 13 2022 *)
PROG
(Python)
from math import gcd
from itertools import count, islice
def agen(): # generator of terms
an = 1
for n in count(2):
yield an
x = gcd(an, n)
an = an + n if x == 1 or x == an else an//x
print(list(islice(agen(), 70))) # Michael S. Branicky, Dec 15 2022
CROSSREFS
KEYWORD
nonn
AUTHOR
Gary Yane, Nov 30 2022
STATUS
approved