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”).

A334840
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
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, 64, 16, 64, 32, 128, 4, 16, 8, 32, 8, 32, 16, 64, 8, 32, 16, 64, 16, 64, 32, 128, 8, 32, 16, 64, 16, 64, 32, 128, 16, 64, 32, 128, 32, 128, 64, 256, 4, 16
OFFSET
1,2
COMMENTS
A variant of A133058. - Ctibor O. Zizka, Apr 14 2023
FORMULA
a(n) = 2^((n mod 2) + A000120(n) + 1), for n >= 2. - Ctibor O. Zizka, Apr 15 2023
a(n) = 2*A001316(n)*(n mod 2 + 1), for n >= 2. - Ctibor O. Zizka, Apr 15 2023
EXAMPLE
a(2) = 4*a(1) = 4, a(3) = 4*a(2) = 16, a(4) = a(3)/4 = 4, a(5) = 4*a(4) = 16, ...
MATHEMATICA
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 *)
PROG
(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
(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
(Python)
from itertools import count, islice
from math import gcd
def A334840_gen(): # generator of terms
yield (a:=1)
for n in count(2):
yield (a:=a<<2 if (b:=gcd(a, n)) == 1 else a//b)
A334840_list = list(islice(A334840_gen(), 30)) # Chai Wah Wu, Mar 18 2023
CROSSREFS
KEYWORD
nonn
AUTHOR
Ctibor O. Zizka, May 13 2020
STATUS
approved