login

Reminder: The OEIS is hiring a new managing editor, and the application deadline is January 26.

a(1)=1; let x=gcd(a(n-1),n); for n > 1, a(n) = a(n-1) + n if x=1 or a(n-1)/x=1, otherwise a(n) = a(n-1)/x.
1

%I #23 Dec 17 2022 08:21:51

%S 1,3,6,3,8,4,11,19,28,14,25,37,50,25,5,21,38,19,38,19,40,20,43,67,92,

%T 46,73,101,130,13,44,11,44,22,57,19,56,28,67,107,148,74,117,161,206,

%U 103,150,25,74,37,88,22,75,25,5,61,118,59,118,59,120,60,20,5,70,35,102,3,72,36

%N a(1)=1; let x=gcd(a(n-1),n); for n > 1, a(n) = a(n-1) + n if x=1 or a(n-1)/x=1, otherwise a(n) = a(n-1)/x.

%H Michael De Vlieger, <a href="/A358787/a358787.png">Log log scatterplot of a(n)</a>, n = 1..2^20.

%H Michael De Vlieger, <a href="/A358787/a358787_1.png">Log log scatterplot of a(n)</a>, 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.

%e For n=2, gcd(2,1)=1 so a(2) = 2+1 = 3.

%e For n=3, gcd(3,3)=3=a(2) so a(3) = 3+3 = 6.

%e For n=4, gcd(4,6)=2 so a(4) = 6/2 = 3.

%t 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 *)

%o (Python)

%o from math import gcd

%o from itertools import count, islice

%o def agen(): # generator of terms

%o an = 1

%o for n in count(2):

%o yield an

%o x = gcd(an, n)

%o an = an + n if x == 1 or x == an else an//x

%o print(list(islice(agen(), 70))) # _Michael S. Branicky_, Dec 15 2022

%Y Cf. A264767, A133058, A133579, A133580, A255051, A255140, A262922.

%K nonn

%O 1,2

%A _Gary Yane_, Nov 30 2022