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.

Showing 1-1 of 1 results.

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

Original entry on oeis.org

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, 46, 73, 101, 130, 13, 44, 11, 44, 22, 57, 19, 56, 28, 67, 107, 148, 74, 117, 161, 206, 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
Offset: 1

Views

Author

Gary Yane, Nov 30 2022

Keywords

Examples

			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.
		

Crossrefs

Programs

  • 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 *)
  • 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
Showing 1-1 of 1 results.