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.

Previous Showing 11-20 of 26 results. Next

A381466 a(0) = 4; for n > 0, a(n) = a(n-1) + n if G = 1 or a(n) = n/G if G > 1, where G = gcd(a(n-1), n).

Original entry on oeis.org

4, 5, 7, 10, 2, 7, 13, 20, 2, 11, 21, 32, 3, 16, 7, 22, 8, 25, 43, 62, 10, 31, 53, 76, 6, 31, 57, 9, 37, 66, 5, 36, 8, 41, 75, 7, 43, 80, 19, 58, 20, 61, 103, 146, 22, 67, 113, 160, 3, 52, 25, 76, 13, 66, 9, 64, 7, 64, 29, 88, 15, 76, 31, 94, 32, 97, 163, 230, 34, 103, 173, 244
Offset: 0

Views

Author

Sam Chapman, Feb 24 2025

Keywords

Comments

If a(n) < n for some n, then a(n+1) > n+1.
If a(n) > n, a(n+1) > n+1, and a(n+2) > n+2 for some n, then a(n+3) < n+3.
1 < a(n) for all n.
sqrt(n/6) < a(n) <= 7n/2 - 9/2 for all n.
a(p)>p for all primes p.
If one were to use the same rule to generate this sequence with any other initial value that is congruent to 4 or 8 (mod 12), that sequence would agree with this one for all n>3.
If one were to use the same rule to generate this sequence with an initial term that is not congruent to 4 or 8 (mod 12), then it would output the number 1 before the 5th term. When a sequence follows a(n)’s rules and outputs the number 1 at some index k, one gets the following quasi-periodic behavior: 1, k+2, 1, k+4, 1, k+6, etc., and are as such “boring” sequences.

Examples

			a(12) = 3 and gcd(3, 13) = 1, so a(13) = 3 + 13 = 16.  gcd(16, 14) = 2, so a(14) = 14/2 = 7.
		

Crossrefs

Similar to A133058, A091508.

Programs

  • Mathematica
    s={4};Do[G=GCD[s[[-1]],n];AppendTo[s,If[G==1,s[[-1]]+n,n/G]],{n,71}];s (* James C. McMahon, Mar 02 2025 *)
  • PARI
    lista(nn) = my(v = vector(nn)); v[1] = 4; for (n=2, nn, my(g=gcd(v[n-1], n-1)); if (g==1, v[n] = v[n-1] + n-1, v[n] = (n-1)/g);); v; \\ Michel Marcus, Feb 26 2025

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

A264767 a(1)=1; for n>1, a(n) = a(n-1) + n if x=0, otherwise a(n) = a(n-1) / 2^x, where x is the exponent of highest power of 2 dividing gcd(a(n-1),n).

Original entry on oeis.org

1, 3, 6, 3, 8, 4, 11, 19, 28, 14, 25, 37, 50, 25, 40, 5, 22, 11, 30, 15, 36, 18, 41, 65, 90, 45, 72, 18, 47, 77, 108, 27, 60, 30, 65, 101, 138, 69, 108, 27, 68, 34, 77, 121, 166, 83, 130, 65, 114, 57, 108, 27, 80, 40, 95, 151, 208, 104, 163, 223, 284, 142, 205, 269, 334, 167, 234, 117, 186, 93, 164, 41, 114, 57, 132, 33, 110, 55, 134, 67, 148, 74, 157, 241, 326, 163, 250, 125, 214, 107, 198, 99, 192, 96, 191, 287, 384, 192, 291, 391, 492, 246
Offset: 1

Views

Author

Ctibor O. Zizka, Nov 23 2015

Keywords

Crossrefs

Programs

  • Mathematica
    nxt[{n_,a_}]:=Module[{x=IntegerExponent[GCD[a,n+1],2]},{n+1,If[x== 0,a+n+1,a/2^x]}]; NestList[nxt,{1,1},110][[All,2]]

A309665 a(1)=1; for n > 1, a(n) = a(n-1)/gcd(a(n-1),n) + n + 1.

Original entry on oeis.org

1, 4, 8, 7, 13, 20, 28, 16, 26, 24, 36, 16, 30, 30, 18, 26, 44, 41, 61, 82, 104, 75, 99, 58, 84, 69, 51, 80, 110, 42, 74, 70, 104, 87, 123, 78, 116, 97, 137, 178, 220, 153, 197, 242, 288, 191, 239, 288, 338, 220, 272, 121, 175, 230, 102, 108, 94, 106, 166
Offset: 1

Views

Author

Dennis Reichard, Aug 11 2019

Keywords

Comments

n is a lower bound on a(n), furthermore n+3 is a lower bound if n > 2. This can easily be proved by induction. It appears that both the average value and the upper bound grow either linearly or slightly faster than linearly.

Examples

			a(4) = a(3)/gcd(a(3),4) + 4 + 1 = 8/gcd(8,4) + 5 = 8/4 + 5 = 2 + 5 = 7.
		

Crossrefs

Cf. A133058.

Programs

  • Magma
    [n le 1 select 1 else  Self(n-1)/Gcd(Floor(Self(n-1)),n) + n + 1 : n in [1..60]]; // Marius A. Burtea, Aug 11 2019
  • Mathematica
    a[1] = 1; a[n_] := a[n] = a[n-1]/GCD[a[n - 1], n] + n + 1; Array[a, 60] (* Amiram Eldar, Aug 14 2019 *)

A322558 a(0)=1, a(1)=1; for n>1, a(n)=a(n-1)+a(n-2) if a(n-1) is less than or equal to n-1, otherwise a(n)=a(n-1)-(n-1).

Original entry on oeis.org

1, 1, 2, 3, 5, 1, 6, 7, 13, 5, 18, 8, 26, 14, 1, 15, 16, 31, 14, 45, 26, 6, 32, 10, 42, 18, 60, 34, 7, 41, 12, 53, 22, 75, 42, 8, 50, 14, 64, 26, 90, 50, 9, 59, 16, 75, 30, 105, 58, 10, 68, 18, 86, 34, 120, 66, 11, 77, 20, 97, 38, 135, 74, 12, 86, 22, 108, 42, 150, 82, 13, 95, 24, 119, 46, 165, 90, 14, 104, 26
Offset: 0

Views

Author

Jackson Haselhorst, Aug 28 2019

Keywords

Comments

The graph of the sequence appears random until n>16, after which the graph creates seven distinct lines.

Crossrefs

Programs

  • Mathematica
    a[0] = a[1] = 1; a[n_] := a[n] = If[a[n - 1] <= n - 1, a[n - 1] + a[n - 2], a[n - 1] - n + 1]; Array[a, 100, 0] (* Amiram Eldar, Aug 29 2019 *)
  • PARI
    Vec((1 + x + 2*x^2 + 3*x^3 + 5*x^4 + x^5 + 6*x^6 + 5*x^7 + 11*x^8 + x^9 + 12*x^10 - 2*x^11 + 24*x^12 + 2*x^13 - 12*x^14 - 10*x^15 + 8*x^16 - 2*x^17 + 3*x^18 - 6*x^19 + 4*x^20 + 11*x^21 + 15*x^22 - 17*x^23 - 2*x^24 - 2*x^25 - 4*x^26 - 4*x^27 - 4*x^28 - 8*x^29 + 8*x^30) / ((1 - x)^2*(1 + x + x^2 + x^3 + x^4 + x^5 + x^6)^2) + O(x^40)) \\ Colin Barker, Aug 29 2019

Formula

For n>16, the sequence follows a pattern of seven, and each term lies on one of the following lines:
If n is of the form 7k+3, then a(n) = (11/7)n+(30/7);
if n is of the form 7k+4, then a(n) = (4/7)n+(26/7);
if n is of the form 7k+5, then a(n) = (15/7)n+(30/7);
if n is of the form 7k+6, then a(n) = (8/7)n+(22/7);
if n is of the form 7k, then a(n) = (1/7)n+3;
if n is of the form 7k+1, then a(n) = (9/7)n+(26/7);
if n is of the form 7k+2, then a(n) = (2/7)n+(24/7).
From Colin Barker, Aug 29 2019: (Start)
G.f.: (1 + x + 2*x^2 + 3*x^3 + 5*x^4 + x^5 + 6*x^6 + 5*x^7 + 11*x^8 + x^9 + 12*x^10 - 2*x^11 + 24*x^12 + 2*x^13 - 12*x^14 - 10*x^15 + 8*x^16 - 2*x^17 + 3*x^18 - 6*x^19 + 4*x^20 + 11*x^21 + 15*x^22 - 17*x^23 - 2*x^24 - 2*x^25 - 4*x^26 - 4*x^27 - 4*x^28 - 8*x^29 + 8*x^30) / ((1 - x)^2*(1 + x + x^2 + x^3 + x^4 + x^5 + x^6)^2).
a(n) = 2*a(n-7) - a(n-14) for n>30.
(End)

A334943 a(1) = 1, a(n) = a(n-1) / gcd(a(n-1),n) if this gcd is > 1, else a(n) = 3*a(n-1) + n + 1.

Original entry on oeis.org

1, 6, 2, 1, 9, 3, 17, 60, 20, 2, 18, 3, 23, 84, 28, 7, 39, 13, 59, 198, 66, 3, 33, 11, 59, 204, 68, 17, 81, 27, 113, 372, 124, 62, 222, 37, 1, 42, 14, 7, 63, 3, 53, 204, 68, 34, 150, 25, 125, 5, 67, 254, 816, 136, 464, 58, 232, 4, 72, 6, 80, 40, 184, 23, 135
Offset: 1

Views

Author

Ctibor O. Zizka, May 17 2020

Keywords

Comments

A variant of A133058. The behavior of simple computational models of the form a(1), a(n) = a(n-1) / gcd(a(n-1),n) if this gcd is > 1, else a(n) = X*a(n-1) + Y*n + R, depending on parameters [X, Y, R], shows Wolfram complexity classes for cellular automata.

Examples

			a(2) = 3*a(1) + 2 + 1 = 6, a(3) = a(2)/3 = 2, a(4) = a(3)/2 = 1, a(5) = 3*a(4) + 5 + 1 = 9, ...
		

Crossrefs

Cf. A133058.

Programs

  • Magma
    a:=[1]; for n in [2..70] do if Gcd(a[n-1], n) eq 1 then Append(~a, 3* a[n-1]+n+1); else Append(~a, a[n-1] div Gcd(a[n-1], n)); end if; end for; a; // Marius A. Burtea, May 17 2020
  • Maple
    N:= 100: # for a(1)..a(N)
    V:= Vector(N):
    V[1]:= 1:
    for n from 2 to N do
      g:= igcd(V[n-1],n);
      if g > 1 then V[n]:= V[n-1]/g else V[n]:= 3*V[n-1]+n+1 fi
    od:
    convert(V,list); # Robert Israel, Jun 22 2020
  • Mathematica
    a[1] = 1; a[n_] := a[n] = If[(g = GCD[a[n-1], n]) > 1, a[n-1]/g, 3*a[n-1] + n + 1]; Array[a, 100]
    nxt[{n_,a_}]:=With[{c=GCD[a,n+1]},{n+1,If[c>1,a/c,3a+n+2]}]; NestList[nxt,{1,1},70][[;;,2]] (* Harvey P. Dale, May 14 2024 *)
  • 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] = 3*va[n-1]+n+1);); va;} \\ Michel Marcus, May 17 2020
    

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

Original entry on oeis.org

1, 1, 3, 5, 9, 15, 8, 24, 4, 7, 12, 20, 8, 7, 16, 24, 5, 30, 7, 38, 46, 42, 44, 43, 88, 132, 5, 138, 144, 47, 192, 240, 9, 83, 93, 177, 90, 89, 180, 270, 5, 55, 12, 68, 20, 22, 21, 44, 66, 5, 72, 78, 25, 104, 130, 9, 140, 150, 29, 180, 210, 13, 224, 238, 33, 272, 306
Offset: 0

Views

Author

Ian Band, Sep 16 2019

Keywords

Comments

The sequence increases rapidly after n = 92.
From roughly n = 480 to n = 600, the sequence increases relatively fast and is almost a perfect exponential function.
Redefining a(0) and a(1) can result in drastically different sequences.

Crossrefs

Cf. A133058.

Programs

  • Magma
    a:=[1,1]; for n in [3..67] do  if Gcd(a[n-1],a[n-2]) ne 1 then Append(~a,(a[n-1]+a[n-2])/Gcd(a[n-1],a[n-2])); else Append(~a,a[n-1]+a[n-2]+1); end if; end for; a; // Marius A. Burtea, Sep 19 2019
  • Mathematica
    a[0]=a[1]=1; a[n_] := a[n] = Block[{g = GCD[a[n-1], a[n-2]]}, If[g==1,
    a[n-1] + a[n-2] + 1, (a[n-1] + a[n-2])/g]]; Array[a, 67, 0] (* Giovanni Resta, Sep 19 2019 *)
    nxt[{a_,b_}]:={b,If[!CoprimeQ[a,b],(a+b)/GCD[a,b],a+b+1]}; NestList[nxt,{1,1},70][[;;,1]] (* Harvey P. Dale, Feb 14 2024 *)
  • Python
    import math
    def a(n): # Iteratively generates an array containing the first n terms of a(n), n should be greater than 2
        a1 = 1 # this will hold a(n-1), its initial value is a(1)
        a2 = 1 # this will hold a(n-2), its initial value is a(0)
        terms = [None] * n
        terms[0] = a2
        terms[1] = a1
        for i in range(2, n):
            gcdPrev2 = math.gcd(a1, a2)
            if(gcdPrev2 > 1):
                terms[i] = int((a1 + a2) / gcdPrev2)
            else:
                terms[i] = a1 + a2 + 1
            a2 = a1
            a1 = terms[i]
        return terms
    

Formula

a(0) = a(1) = 1; for n > 1, a(n) = (a(n-1) + a(n-2)) / gcd(a(n-1), a(n-2)) if gcd(a(n-1), a(n-2)) > 1, otherwise a(n) = a(n-1) + a(n-2) + 1.

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

A372748 a(1) = 3; for n > 1, a(n) = a(n - 1) if GCD(n - 1, a(n - 1)) = 1, otherwise a(n) = n - 1 - a(n - 1) / GCD(n - 1, a(n - 1)).

Original entry on oeis.org

3, 3, 3, 2, 3, 3, 5, 5, 5, 5, 9, 9, 9, 9, 9, 12, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 25, 25, 25, 25, 25, 25, 25, 25, 25, 30, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 61, 61, 61, 61, 61, 61, 61, 61
Offset: 1

Views

Author

Ctibor O. Zizka, May 12 2024

Keywords

Comments

a(n) = n/2 for n from {4,6,10,26,62,122,298,626,1094,2186,...}.

Examples

			a(1) = 3.
a(2) = 3 because GCD(1,3) = 1.
a(3) = 3 because GCD(2,3) = 1.
a(4) = 3 - 3/GCD(3,3) = 2.
and so on.
		

Crossrefs

Programs

  • Mathematica
    nxt[{n_,a_}]:={n+1,If[GCD[n,a]==1,a,n-a/GCD[n,a]]}; NestList[nxt,{1,3},70][[;;,2]] (* Harvey P. Dale, Feb 11 2025 *)
    FoldList[If[CoprimeQ[#, #2], #, #2 - #/GCD[#, #2]] &, 3, Range[100]] (* Paolo Xausa, Feb 12 2025 *)

A381331 a(1) = a(2) = 1; for n > 2, a(n) = floor((n - 2)*a(n - 1)/a(n - 2)) + GCD(n - 2, a(n - 2)).

Original entry on oeis.org

1, 1, 2, 5, 8, 7, 5, 5, 8, 13, 15, 12, 9, 21, 31, 27, 14, 9, 11, 31, 54, 35, 16, 11, 16, 35, 55, 41, 21, 15, 21, 57, 85, 48, 19, 15, 28, 70, 93, 52, 24, 22, 38, 74, 84, 51, 30, 28, 44, 79, 88, 56, 33, 34, 55, 89, 144, 91, 39, 25, 38, 96, 155, 102, 42, 28, 44, 105, 160, 104
Offset: 1

Views

Author

Ctibor O. Zizka, Feb 20 2025

Keywords

Comments

At n = 499 the sequence settles down and becomes quasi-periodic with a 6-loop. Empiricaly 3 >= a(n + 1)/a(n) >= 1/3. The system is sensitive to the choice of initial terms [a(1),a(2)]. Only some values of initial terms results in a 6-loop like this sequence, the vast majority of initial terms show a "noisy quasiperiodic" like structures in the plot. Trials made for [a(1), a(2)] from [1, 1] to [100, 100] and for n up to 70000. May it be the sequence converges to a 6-loop for some large enough n, independent on the choice of initial terms ?

Examples

			a(1) = 1
a(2) = 1
a(3) = floor(1*1/1) + GCD(1,1) = 2
a(4) = floor(2*2/1) + GCD(2,1) = 5
a(5) = floor(3*5/2) + GCD(3,2) = 8
and so on.
		

Crossrefs

Programs

  • Mathematica
    a[n_] := a[n] = If[n < 3, 1, Floor[(n-2)*a[n-1]/a[n-2]] + GCD[n-2, a[n-2]]]; Array[a, 70] (* Amiram Eldar, Feb 20 2025 *)

Formula

For n >= 499:
if n mod 6 = 0, a(n) = 2*n - 1 + 2*((n/2) mod 2).
if n mod 6 = 1, a(n) = n + 2.
if n mod 6 = 2, a(n) = (n + 2)/2.
if n mod 6 = 3, a(n) = (n - 1)/2.
if n mod 6 = 4, a(n) = n - 2 - (n/2) mod 2.
if n mod 6 = 5, a(n) = 2*n - 6 + 3*((n + 1)/2 mod 2).
Previous Showing 11-20 of 26 results. Next