login

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

a(1) = 1, a(n) = a(n-1)/gcd(a(n-1),n) if this gcd is > 1, else a(n) = 4*a(n-1).
0

%I #33 Apr 16 2023 21:08:23

%S 1,4,16,4,16,8,32,4,16,8,32,8,32,16,64,4,16,8,32,8,32,16,64,8,32,16,

%T 64,16,64,32,128,4,16,8,32,8,32,16,64,8,32,16,64,16,64,32,128,8,32,16,

%U 64,16,64,32,128,16,64,32,128,32,128,64,256,4,16

%N a(1) = 1, a(n) = a(n-1)/gcd(a(n-1),n) if this gcd is > 1, else a(n) = 4*a(n-1).

%C A variant of A133058. - _Ctibor O. Zizka_, Apr 14 2023

%F a(n) = 2^((n mod 2) + A000120(n) + 1), for n >= 2. - _Ctibor O. Zizka_, Apr 15 2023

%F a(n) = 2*A001316(n)*(n mod 2 + 1), for n >= 2. - _Ctibor O. Zizka_, Apr 15 2023

%e a(2) = 4*a(1) = 4, a(3) = 4*a(2) = 16, a(4) = a(3)/4 = 4, a(5) = 4*a(4) = 16, ...

%t a[1] = 1; a[n_] := a[n] = If[(g = GCD[a[n-1], n]) > 1, a[n-1]/g, 4*a[n-1]]; Array[a, 100] (* _Amiram Eldar_, May 13 2020 *)

%o (Magma) a:=[1]; for n in [2..70] do if Gcd(a[n-1], n) eq 1 then Append(~a,4* a[n-1]); else Append(~a, a[n-1] div Gcd(a[n-1], n)); end if; end for; a; // _Marius A. Burtea_, May 13 2020

%o (PARI) lista(nn) = {my(va = vector(nn)); va[1] = 1; for (n=2, nn, my(g = gcd(va[n-1], n)); if (g > 1, va[n] = va[n-1]/g, va[n] = 4*va[n-1]);); va;} \\ _Michel Marcus_, May 17 2020

%o (Python)

%o from itertools import count, islice

%o from math import gcd

%o def A334840_gen(): # generator of terms

%o yield (a:=1)

%o for n in count(2):

%o yield (a:=a<<2 if (b:=gcd(a,n)) == 1 else a//b)

%o A334840_list = list(islice(A334840_gen(),30)) # _Chai Wah Wu_, Mar 18 2023

%Y Cf. A000120, A001316, A133058, A255140, A257806, A319018.

%K nonn

%O 1,2

%A _Ctibor O. Zizka_, May 13 2020