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-5 of 5 results.

A133058 a(0) = a(1) = 1; for n > 1, a(n) = a(n-1) + n + 1 if a(n-1) and n are coprime, otherwise a(n) = a(n-1)/gcd(a(n-1),n).

Original entry on oeis.org

1, 1, 4, 8, 2, 8, 4, 12, 3, 1, 12, 24, 2, 16, 8, 24, 3, 21, 7, 27, 48, 16, 8, 32, 4, 30, 15, 5, 34, 64, 32, 64, 2, 36, 18, 54, 3, 41, 80, 120, 3, 45, 15, 59, 104, 150, 75, 123, 41, 91, 142, 194, 97, 151, 206, 262, 131, 189, 248, 308, 77, 139, 202, 266, 133, 199, 266, 334, 167
Offset: 0

Views

Author

Ctibor O. Zizka, Dec 16 2007

Keywords

Comments

Remarkably, at n = 638 the sequence settles down and becomes quasi-periodic. - N. J. A. Sloane, Feb 22 2015. (Whenever I look at this sequence I am reminded of the great "Fly straight, dammit" scene in the movie "Avatar". - N. J. A. Sloane, Aug 06 2019)
For every choice of initial term a(0) there exist integers r and t >= 0 such that a(2*r+4*t+0) = 1, a(2*r+4*t+1) = 2*r+4*t+3, a(2*r+4*t+2) = 2*(2*r+4*t+3), a(2*r+4*t+3) = 2. - Ctibor O. Zizka, Dec 26 2007
See also the variants A255051 (which starts immediately with the same (1, x, 2x, 2) loop that the present sequence enters at n >= 641) and A255140 (which enters a different loop at n = 82). - M. F. Hasler, Feb 15 2015
With the recurrence used here (but with different starting values), if at some point we find a(2k) = 1, then from that point on the sequence looks like (1, x, 2x, 2), (1, x+4, 2(x+4), 2), (1, x+8, 2(x+8), 2), (1, x+12, 2(x+12), 2), ... where x = 2k+3. This is just a restatement of Zizka's comment above (although I have not seen a proof that this must always happen). - N. J. A. Sloane, Feb 22 2015
It is conjectured that quasi-periodic sequences exist only for R = 0, 1, 2 or 3 in a(n) = a(n-1) + n + R and that for R >= 4 the recurrence is not quasi-periodic. For R = 0, 1, 2 all starting values give a quasi-periodic sequence. The respective loop is (1, x) for R = 0, (1, x, 2x, 2) for R = 1 (this sequence), (1, x, 2x, x) or (2x, x) for R = 2. For R = 3 only some starting values converge to a 6-loop (4x+2, 2x+1, 3x+6, x+2, 2x+9, 3x+17). - Ctibor O. Zizka, Oct 27 2015

Crossrefs

Programs

  • Magma
    a:=[1]; for n in [2..70] do if Gcd(a[n-1],n) eq 1 then Append(~a, a[n-1] + n + 1); else Append(~a, a[n-1] div Gcd(a[n-1],n)); end if; end for; [1] cat a; // Marius A. Burtea, Jan 12 2020
    
  • Maple
    A[0]:= 1: A[1]:= 1:
    for n from 2 to 1000 do
      g:= igcd(A[n-1],n);
      A[n]:= A[n-1]/g + `if`(g=1, n+1, 0);
    od:
    seq(A[i],i=0..1000); # Robert Israel, Nov 06 2015
  • Mathematica
    nxt[{n_,a_}]:={n+1,If[CoprimeQ[a,n+1],a+n+2,a/GCD[a,n+1]]}; Join[{1}, Transpose[ NestList[nxt,{1,1},70]][[2]]] (* Harvey P. Dale, Feb 14 2015 *)
  • PARI
    (A133058_upto(N)=vector(N, n, if(gcd(N,n-1)>1 || n<3, N\=gcd(N,n-1), N+=n)))(100) \\ M. F. Hasler, Feb 15 2015, simplified Jan 11 2020
    
  • Python
    from itertools import count, islice
    from math import gcd
    def A133058_gen(): # generator of terms
        a = 1
        yield from (1,1)
        for n in count(2):
            yield (a:=a+n+1 if (b:=gcd(a,n)) == 1 else a//b)
    A133058_list = list(islice(A133058_gen(),30)) # Chai Wah Wu, Mar 18 2023

Extensions

More terms from Ctibor O. Zizka, Dec 26 2007
Offset and definition corrected by N. J. A. Sloane, Feb 13 2015

A133579 a(0)=a(1)=1; for n > 1, a(n) = 3*a(n-1) if a(n-1) and n are coprime, otherwise a(n) = a(n-1)/gcd(a(n-1), n).

Original entry on oeis.org

1, 1, 3, 1, 3, 9, 3, 9, 27, 3, 9, 27, 9, 27, 81, 27, 81, 243, 27, 81, 243, 81, 243, 729, 243, 729, 2187, 81, 243, 729, 243, 729, 2187, 729, 2187, 6561, 729, 2187, 6561, 2187, 6561, 19683, 6561, 19683, 59049, 6561, 19683, 59049, 19683, 59049, 177147
Offset: 0

Views

Author

Ctibor O. Zizka, Dec 26 2007

Keywords

Crossrefs

Programs

  • Maple
    f:=proc(n) option remember;
    if n <= 1 then 1
    elif gcd(n,f(n-1))>1 then f(n-1)/gcd(n,f(n-1))
    else 3*f(n-1); fi; end;
    [seq(f(n),n=0..50)];
    # N. J. A. Sloane, Feb 14 2015
  • Mathematica
    nxt[{n_,a_}]:={n+1,If[CoprimeQ[a,n+1],3a,a/GCD[a,n+1]]}; Join[{1}, Transpose[ NestList[nxt,{1,1},50]][[2]]] (* Harvey P. Dale, Feb 14 2015 *)
  • PARI
    A=vector(1000,i,1);for(n=2,#A,A[n]=if(gcd(A[n-1],n)>1,A[n-1]/gcd(A[n-1],n),A[n-1]*3)) \\ M. F. Hasler, Feb 15 2015

Extensions

Offset, definition, and terms corrected by N. J. A. Sloane, Feb 14 2015

A262922 a(1)=1; for n>1, a(n) = a(n-1) + n + 2 if a(n-1) and n are coprime, otherwise a(n) = a(n-1)/gcd(a(n-1),n).

Original entry on oeis.org

1, 5, 10, 5, 1, 9, 18, 9, 1, 13, 26, 13, 1, 17, 34, 17, 1, 21, 42, 21, 1, 25, 50, 25, 1, 29, 58, 29, 1, 33, 66, 33, 1, 37, 74, 37, 1, 41, 82, 41, 1, 45, 90, 45, 1, 49, 98, 49, 1, 53, 106, 53, 1, 57, 114, 57, 1, 61, 122, 61, 1, 65, 130, 65, 1, 69, 138, 69, 1, 73, 146, 73, 1, 77, 154, 77, 1, 81, 162
Offset: 1

Views

Author

Ctibor O. Zizka, Oct 04 2015

Keywords

Comments

This recurrence is quasi-periodic.
For some choice of starting value a(1) there exists an integer t>=1 such that a(4*t-3)=1, a(4*t-2)=4*t+1, a(4*t-1)=2*(4*t+1), a(4*t)=4*t+1. The loop is (1,x,2x,x).
For some choice of starting value a(1) there exists an integer t>=1 such that a(2*t)=2*t-1 and a(2*t-1)=2*(2*t-1). The loop is (x,2x). See also A133058.
Quasi-periodic sequences exist only for R=0,1,2 or 3 in a(n) = a(n-1) + n + R. For R=0,1,2 all starting values give a quasi-periodic sequence. The respective loop is (1,x) for R=0, (1,x,2x,2) for R=1, (1,x,2x,x) or (x,2x) for R=2. For R=3 only some starting values converge to a 6-loop (4x+2,2x+1,3x+6,x+2,2x+9,3x+17). Conjecture: For R>=4 the recurrence is not quasi-periodic.

Crossrefs

Programs

  • Mathematica
    a[1] = 1; a[n_] := a[n] = If[CoprimeQ[a[n - 1], n], a[n - 1] + n + 2, a[n - 1]/GCD[a[n - 1], n]]; Array[a, {79}] (* Michael De Vlieger, Oct 05 2015 *)
  • PARI
    A=vector(1000, i, 1); for(n=2, #A, A[n]=if(gcd(A[n-1], n)>1, A[n-1]/gcd(A[n-1], n), A[n-1]+n+2))

Formula

Maple suggests the rational o.g.f. (-x^6 - x^5 - x^3 + 6x^2 + 4x + 1)/((x + 1)(x - 1)^2(x^2 + 1)^2), which should be easy to check. - Pater Bala, Oct 04 2015

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

A361672 a(1) = a(2) = 1; for n > 2, a(n) = a(n-2) + a(n-1) + n if a(n-1) and n are coprime, otherwise a(n) = a(n-1)/gcd(a(n-1), n).

Original entry on oeis.org

1, 1, 5, 10, 2, 1, 10, 5, 24, 12, 47, 71, 131, 216, 72, 9, 98, 49, 166, 83, 270, 135, 428, 107, 560, 280, 867, 1175, 2071, 3276, 5378, 2689, 8100, 4050, 810, 45, 892, 446, 1377, 1863, 3281, 5186, 8510, 4255, 851, 37, 935, 1020, 2004, 1002, 334, 167, 554, 277, 886
Offset: 1

Views

Author

Hubert W. Westwood, Mar 20 2023

Keywords

Crossrefs

Programs

  • Magma
    a:=[1, 1]; for n in [3..50] do if Gcd(a[n-1], n) eq 1 then Append(~a, a[n-2] + a[n-1] + n); else Append(~a, a[n-1] div Gcd(a[n-1], n)); end if; end for; [] cat a;
  • Mathematica
    a[1]=a[2]=1; a[n_]:=a[n]=If[GCD[a[n-1],n]==1,a[n-2]+a[n-1]+n,a[n-1]/GCD[a[n-1],n]]; Array[a,55] (* Stefano Spezia, Mar 20 2023 *)
Showing 1-5 of 5 results.