cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

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

Original entry on oeis.org

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

Views

Author

Ctibor O. Zizka, May 13 2020

Keywords

Comments

A variant of A133058. - Ctibor O. Zizka, Apr 14 2023

Examples

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

Crossrefs

Programs

  • 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
    
  • 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 *)
  • 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

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