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 21-30 of 37 results. Next

A283880 A linear-recurrent solution to Hofstadter's Q recurrence.

Original entry on oeis.org

12, 6, 4, 6, 1, 6, 12, 10, 4, 6, 13, 6, 12, 16, 4, 6, 25, 6, 12, 26, 4, 6, 37, 6, 12, 42, 4, 6, 49, 6, 12, 68, 4, 6, 61, 6, 12, 110, 4, 6, 73, 6, 12, 178, 4, 6, 85, 6, 12, 288, 4, 6, 97, 6, 12, 466, 4, 6, 109, 6, 12, 754, 4, 6, 121, 6, 12, 1220, 4, 6, 133, 6, 12, 1974, 4
Offset: 1

Views

Author

Nathan Fox, Mar 19 2017

Keywords

Comments

a(n) is the solution to the recurrence relation a(n) = a(n-a(n-1)) + a(n-a(n-2)) [Hofstadter's Q recurrence], with the initial conditions: a(n) = 0 if n <= 0; a(1) = 12, a(2) = 6, a(3) = 4, a(4) = 6, a(5) = 1, a(6) = 6, a(7) = 12, a(8) = 10, a(9) = 4.
This sequence is an interleaving of six simpler sequences. Four are constant, one is a linear polynomial, and one is a Fibonacci-like sequence.

Crossrefs

Programs

  • Maple
    A283880:=proc(n) option remember: if n <= 0 then 0: elif n = 1 then 12: elif n = 2 then 6: elif n = 3 then 4: elif n = 4 then 6: elif n = 5 then 1: elif n = 6 then 6: elif n = 7 then 12: elif n = 8 then 10: elif n = 9 then 4: else A283880(n-A283880(n-1)) + A283880(n-A283880(n-2)): fi: end:
  • Python
    from functools import cache
    @cache
    def a(n):
        if n <= 0: return 0
        if n <= 9: return [12, 6, 4, 6, 1, 6, 12, 10, 4][n-1]
        return a(n - a(n-1)) + a(n - a(n-2))
    print([a(n) for n in range(1, 76)]) # Michael S. Branicky, Dec 06 2021

Formula

a(6n) = 6, a(6n+1) = 12, a(6n+2) = 2*F(n+4), a(6n+3) = 4, a(6n+4) = 6, a(6n+5) = 12n+1.
G.f.: (-6*x^23+11*x^22-6*x^21-4*x^20-4*x^19-12*x^18+12*x^16+2*x^13 +12*x^11 -10*x^10 +12*x^9+8*x^8 +8*x^7+24*x^6-6*x^5-x^4-6*x^3-4*x^2 -6*x-12) / ((-1+x^6+x^12) *(-1+x)^2*(1+x)^2*(1+x+x^2)^2*(1-x+x^2)^2).
a(n) = 3*a(n-6) - 2*a(n-12) - a(n-18) + a(n-24) for n > 24.

A283881 A linear-recurrent solution to Hofstadter's Q recurrence.

Original entry on oeis.org

7, 0, 8, 7, 7, 8, 4, 7, 7, 16, 7, 7, 16, 4, 7, 14, 24, 7, 7, 32, 4, 7, 21, 32, 7, 7, 64, 4, 7, 28, 40, 7, 7, 128, 4, 7, 35, 48, 7, 7, 256, 4, 7, 42, 56, 7, 7, 512, 4, 7, 49, 64, 7, 7, 1024, 4, 7, 56, 72, 7, 7, 2048, 4, 7, 63, 80, 7, 7, 4096, 4, 7, 70, 88, 7, 7
Offset: 1

Views

Author

Nathan Fox, Mar 19 2017

Keywords

Comments

a(n) is the solution to the recurrence relation a(n) = a(n-a(n-1)) + a(n-a(n-2)) [Hofstadter's Q recurrence], with the initial conditions: a(n) = 0 if n <= 0; a(1) = 7, a(2) = 0, a(3) = 8, a(4) = 7, a(5) = 7, a(6) = 8, a(7) = 4.
This sequence is an interleaving of seven simpler sequences. Four are constant, two are linear polynomials, and one is a geometric sequence.

Crossrefs

Programs

  • Maple
    A283881:=proc(n) option remember: if n <= 0 then 0: elif n = 1 then 7: elif n = 2 then 0: elif n = 3 then 8: elif n = 4 then 7: elif n = 5 then 7: elif n = 6 then 8: elif n = 7 then 4: else A283881(n-A283881(n-1)) + A283881(n-A283881(n-2)): fi: end:

Formula

a(7n) = 4, a(7n+1) = 7, a(7n+2) = 7n, a(7n+3) = 8n+8, a(7n+4) = 7, a(7n+5) = 7, a(7n+6) = 2^(n+3).
G.f.: (-8*x^20-8*x^19-14*x^18-14*x^17+14*x^15-14*x^14+12*x^13 +16*x^12 +21*x^11 +21*x^10+16*x^9-7*x^8+21*x^7-4*x^6-8*x^5-7*x^4-7*x^3 -8*x^2-7) / ((-1+2*x^7)*(-1+x)^2*(1+x+x^2+x^3+x^4+x^5+x^6)^2).
a(n) = 4*a(n-7) - 5*a(n-14) + 2*a(n-21) for n > 21.

A289205 a(1) = a(2) = a(3) = 1, a(4) = 3; a(n) = n - a(n-a(n-1)) - a(n-a(n-2)) for n > 4.

Original entry on oeis.org

1, 1, 1, 3, 1, 4, 2, 1, 6, 1, 9, 2, 1, 11, 1, 14, 2, 1, 16, 1, 19, 2, 1, 21, 1, 24, 2, 1, 26, 1, 29, 2, 1, 31, 1, 34, 2, 1, 36, 1, 39, 2, 1, 41, 1, 44, 2, 1, 46, 1, 49, 2, 1, 51, 1, 54, 2, 1, 56, 1, 59, 2, 1, 61, 1, 64, 2, 1, 66, 1, 69, 2, 1, 71, 1, 74, 2, 1, 76, 1, 79, 2, 1, 81, 1, 84, 2, 1, 86, 1, 89, 2, 1, 91, 1, 94, 2, 1, 96, 1, 99, 2, 1, 101
Offset: 1

Views

Author

Altug Alkan, Jun 28 2017

Keywords

Crossrefs

Cf. A244477.

Programs

  • Mathematica
    LinearRecurrence[{0,0,0,0,2,0,0,0,0,-1},{1,1,1,3,1,4,2,1,6,1,9,2,1,11},120] (* Harvey P. Dale, Aug 20 2017 *)
  • PARI
    q=vector(10^5); q[1]=q[2]=q[3]=1;q[4]=3; for(n=5, #q, q[n] = n-q[n-q[n-1]]-q[n-q[n-2]]); q
    
  • PARI
    Vec(x*(1 + x)*(1 + x^2 + 2*x^3 - x^4 + 3*x^5 - 3*x^6 + 2*x^7 - 2*x^8 + x^9 + x^10 - 2*x^11 + 2*x^12) / ((1 - x)^2*(1 + x + x^2 + x^3 + x^4)^2) + O(x^100)) \\ Colin Barker, Jun 28 2017

Formula

a(5k) = a(5k + 3) = 1, a(5k + 1) = 5k - 1, a(5k + 2) = 2, a(5k + 4) = 5k + 1 for k > 0.
From Colin Barker, Jun 28 2017: (Start)
G.f.: x*(1 + x)*(1 + x^2 + 2*x^3 - x^4 + 3*x^5 - 3*x^6 + 2*x^7 - 2*x^8 + x^9 + x^10 - 2*x^11 + 2*x^12) / ((1 - x)^2*(1 + x + x^2 + x^3 + x^4)^2).
a(n) = 2*a(n-5) - a(n-10) for n>12.
(End)

A296786 a(1) = a(2) = a(5) = 2, a(3) = 1, a(4) = 3, a(6) = 5; a(n) = a(n-a(n-1)) + a(n-a(n-2)) + a(n-a(n-3)) for n > 6.

Original entry on oeis.org

2, 2, 1, 3, 2, 5, 7, 8, 7, 4, 11, 12, 11, 4, 15, 16, 15, 4, 19, 20, 19, 4, 23, 24, 23, 4, 27, 28, 27, 4, 31, 32, 31, 4, 35, 36, 35, 4, 39, 40, 39, 4, 43, 44, 43, 4, 47, 48, 47, 4, 51, 52, 51, 4, 55, 56, 55, 4, 59, 60, 59, 4, 63, 64, 63, 4, 67, 68, 67, 4, 71, 72, 71, 4, 75, 76, 75, 4, 79, 80, 79, 4
Offset: 1

Views

Author

Altug Alkan, Dec 20 2017

Keywords

Comments

A quasi-periodic solution to the three-term Hofstadter recurrence a(n) = a(n-a(n-1)) + a(n-a(n-2)) + a(n-a(n-3)). See comments in A296518.

Crossrefs

Programs

  • Maple
    a:= proc(n) option remember; procname(n-procname(n-1))+procname(n-procname(n-2))+procname(n-procname(n-3)) end proc:
    a(1):= 2: a(2):= 2: a(3):= 1: a(4):= 3: a(5):= 2: a(6):= 5:
    map(a, [$1..100]); # after Robert Israel at A296440
  • Mathematica
    a[n_] := a[n] = If[n<7, {2, 2, 1, 3, 2, 5}[[n]], a[n - a[n-1]] + a[n - a[n-2]] + a[n - a[n-3]]]; Array[a, 100] (* after Giovanni Resta at A296440 *)
  • PARI
    q=vector(10^5); q[1]=2;q[2]=2;q[3]=1;q[4]=3;q[5]=2;q[6]=5;for(n=7, #q, q[n] = q[n-q[n-1]]+q[n-q[n-2]]+q[n-q[n-3]]); q
    
  • PARI
    Vec(x*(2 + 2*x + x^2 + 3*x^3 - 2*x^4 + x^5 + 5*x^6 + 2*x^7 + 5*x^8 - 4*x^9 - 2*x^10 - x^11 - x^12 + x^13) / ((1 - x)^2*(1 + x)^2*(1 + x^2)^2) + O(x^100)) \\ Colin Barker, Dec 29 2017

Formula

a(4*k-1) = a(4*k+1) = 4*k-1, a(4*k) = 4*k, a(4*k+2) = 4, for k > 1.
From Colin Barker, Dec 28 2017: (Start)
G.f.: x*(2 + 2*x + x^2 + 3*x^3 - 2*x^4 + x^5 + 5*x^6 + 2*x^7 + 5*x^8 - 4*x^9 - 2*x^10 - x^11 - x^12 + x^13) / ((1 - x)^2*(1 + x)^2*(1 + x^2)^2).
a(n) = 2*a(n-4) - a(n-8) for n>14.
(End)

A275365 a(1)=2, a(2)=2; thereafter a(n) = a(n-a(n-1)) + a(n-a(n-2)).

Original entry on oeis.org

0, 2, 2, 4, 2, 6, 2, 8, 2, 10, 2, 12, 2, 14, 2, 16, 2, 18, 2, 20, 2, 22, 2, 24, 2, 26, 2, 28, 2, 30, 2, 32, 2, 34, 2, 36, 2, 38, 2, 40, 2, 42, 2, 44, 2, 46, 2, 48, 2, 50, 2, 52, 2, 54, 2, 56, 2, 58, 2, 60, 2, 62, 2, 64, 2, 66, 2, 68, 2, 70, 2, 72, 2, 74
Offset: 0

Views

Author

Nathan Fox, Jul 24 2016

Keywords

Comments

a(n) is the solution to the recurrence relation a(n) = a(n-a(n-1)) + a(n-a(n-2)) [Hofstadter's Q recurrence], with the initial conditions: a(n) = 0 if n <= 0; a(1) = 2, a(2) = 2.
Starting with n=1, a(n) is A005843 interleaved with A007395.
This sequence is the same as A133265 with the leading 2 changed to a 0.

Crossrefs

Programs

  • Mathematica
    Join[{0}, LinearRecurrence[{0, 2, 0, -1}, {2, 2, 4, 2}, 73]] (* Jean-François Alcover, Feb 19 2019 *)

Formula

a(0) = 0; thereafter, a(2n) = 2, a(2n+1) = 2n+2.
a(n) = 2*a(n-2) - a(n-4) for n>4.
G.f.: -(2*x^3 -2*x -2)/((x-1)^2*(x+1)^2).

A283904 Relative of Hofstadter Q-sequence: a(1) = 1, a(2) = 1; thereafter a(n) = a(n-2a(n-1)) + a(n-3a(n-2)).

Original entry on oeis.org

1, 1, 1, 2, 2, 1, 3, 3, 1, 4, 4, 2, 2, 7, 2, 2, 6, 3, 3, 11, 2, 3, 12, 2, 2, 14, 2, 2, 14, 3, 2, 14, 4, 14, 15, 1, 15, 18, 1, 18, 20, 1, 20, 22, 1, 22, 23, 1, 23, 25, 1, 25, 26, 1, 26, 28, 1, 28, 29, 1, 29, 31, 1, 31, 32, 1, 32, 34, 1, 34, 35, 1, 35, 37, 1
Offset: 1

Views

Author

Nathan Fox, Mar 19 2017

Keywords

Comments

This sequence is eventually quasilinear with period 6. Each component sequence has slope 0 or 1/2.

Crossrefs

Programs

Formula

If the index is at least 41:
a(6n) = 1
a(6n+1) = 3n-1
a(6n+2) = 3n+1
a(6n+3) = 1
a(6n+4) = 3n+1
a(6n+5) = 3n+2.
G.f.: (-x^48-x^46-x^45-x^43+x^42+3*x^41+x^40-9*x^39-x^38+3*x^37+x^36-4*x^35+x^34+12*x^33+x^32-2*x^31+x^30+x^29-x^28+x^26-3*x^25-2*x^24-x^23+2*x^22-x^20+2*x^19+3*x^18-2*x^16-x^15+2*x^13-3*x^12+x^11-x^8+x^4+x^3+x^2+x+1) / ((1+x)*(1-x+x^2)*(-1+x)^2*(1+x+x^2)^2).
a(n) = a(n-3) + a(n-6) - a(n-9) for n > 49.

A284429 A quasilinear solution to Hofstadter's Q recurrence.

Original entry on oeis.org

2, 1, 3, 5, 1, 3, 8, 1, 3, 11, 1, 3, 14, 1, 3, 17, 1, 3, 20, 1, 3, 23, 1, 3, 26, 1, 3, 29, 1, 3, 32, 1, 3, 35, 1, 3, 38, 1, 3, 41, 1, 3, 44, 1, 3, 47, 1, 3, 50, 1, 3, 53, 1, 3, 56, 1, 3, 59, 1, 3, 62, 1, 3, 65, 1, 3, 68, 1, 3, 71, 1, 3, 74, 1, 3
Offset: 1

Views

Author

Nathan Fox, Mar 26 2017

Keywords

Comments

a(n) is the solution to the recurrence relation a(n) = a(n-a(n-1)) +a(n-a(n-2)) [Hofstadter's Q recurrence], with the initial conditions: a(1) = 2, a(2) = 1.
This sequence is a close relative of A283878.

Crossrefs

Programs

  • Maple
    A284429:=proc(n) option remember: if n <= 0 then 0: elif n = 1 then 2: elif n = 2 then 1: else A284429(n-A284429(n-1)) + A284429(n-A284429(n-2)): fi: end:
  • Mathematica
    CoefficientList[Series[(-3*x^5 - x^4 + x^3 + 3*x^2 + x + 2) / ((-1 + x)^2*(1 + x + x^2)^2), {x, 0, 100}], x] (* Indranil Ghosh, Mar 27 2017 *)
  • PARI
    Vec((-3*x^5 - x^4 + x^3 + 3*x^2 + x + 2) / ((-1 + x)^2*(1 + x + x^2)^2) + O(x^100)) \\ Indranil Ghosh, Mar 27 2017

Formula

G.f.: (-3*x^5 - x^4 + x^3 + 3*x^2 + x + 2) / ((-1 + x)^2*(1 + x + x^2)^2).
a(n) = 2*a(n-3) - a(n-6) for n > 6.
a(3*k) = 3,
a(3*k+1) = 3*k+2,
a(3*k+2) = 1.

A296337 a(1) = a(3) = 1, a(2) = 2, a(4) = a(5) = 4; a(n) = a(n-a(n-1)) + a(n-a(n-2)) for n > 5.

Original entry on oeis.org

1, 2, 1, 4, 4, 4, 2, 8, 3, 4, 10, 10, 2, 14, 3, 4, 16, 16, 2, 20, 3, 4, 22, 22, 2, 26, 3, 4, 28, 28, 2, 32, 3, 4, 34, 34, 2, 38, 3, 4, 40, 40, 2, 44, 3, 4, 46, 46, 2, 50, 3, 4, 52, 52, 2, 56, 3, 4, 58, 58, 2, 62, 3, 4, 64, 64, 2, 68, 3, 4, 70, 70, 2, 74, 3, 4, 76, 76, 2, 80, 3, 4, 82, 82
Offset: 1

Views

Author

Altug Alkan, Dec 10 2017

Keywords

Crossrefs

Cf. A244477.

Programs

  • Mathematica
    Fold[Append[#1, #1[[#2 - #1[[#2 - 1]] ]] + #1[[#2 - #1[[#2 - 2]] ]] ] &, {1, 2, 1, 4, 4}, Range[6, 84]] (* Michael De Vlieger, Dec 11 2017 *)
  • PARI
    q=vector(10^5); q[1]=1;q[2]=2;q[3]=1;q[4]=4;q[5]=4;for(n=6, #q, q[n] = q[n-q[n-1]]+q[n-q[n-2]]); q
    
  • PARI
    Vec(x*(1 + 2*x + x^2 + 4*x^3 + 4*x^4 + 4*x^5 + 4*x^7 + x^8 - 4*x^9 + 2*x^10 + 2*x^11 - x^12 - 2*x^14) / ((1 - x)^2*(1 + x)^2*(1 - x + x^2)^2*(1 + x + x^2)^2) + O(x^40)) \\ Colin Barker, Dec 11 2017

Formula

a(6*k + 1) = 2, a(6*k - 4) = 6*k - 4, a(6*k + 3) = 3, a(6*k - 2) = 4, a(6*k - 1) = a(6*k) = 6*k - 2 for k >= 1. - Iain Fox, Dec 10 2017
From Colin Barker, Dec 11 2017: (Start)
G.f.: x*(1 + 2*x + x^2 + 4*x^3 + 4*x^4 + 4*x^5 + 4*x^7 + x^8 - 4*x^9 + 2*x^10 + 2*x^11 - x^12 - 2*x^14) / ((1 - x)^2*(1 + x)^2*(1 - x + x^2)^2*(1 + x + x^2)^2).
a(n) = 2*a(n-6) - a(n-12) for n>13.
(End)

A302130 a(n) = a(a(n-3)) + a(n-a(n-2)) with a(1) = a(2) = a(3) = a(4) = 1, a(5) = 2, a(6) = 5.

Original entry on oeis.org

1, 1, 1, 1, 2, 5, 3, 2, 7, 3, 2, 10, 3, 2, 13, 3, 2, 16, 3, 2, 19, 3, 2, 22, 3, 2, 25, 3, 2, 28, 3, 2, 31, 3, 2, 34, 3, 2, 37, 3, 2, 40, 3, 2, 43, 3, 2, 46, 3, 2, 49, 3, 2, 52, 3, 2, 55, 3, 2, 58, 3, 2, 61, 3, 2, 64, 3, 2, 67, 3, 2, 70, 3, 2, 73, 3, 2, 76, 3, 2, 79, 3, 2, 82, 3, 2, 85, 3, 2, 88
Offset: 1

Views

Author

Altug Alkan, Jun 20 2018

Keywords

Comments

A quasi-periodic solution to the recurrence a(n) = a(a(n-3)) + a(n-a(n-2)).

Examples

			a(3*k-2) = 3, a(3*k-1) = 2, a(3*k) = 3*k - 2 for k > 2.
		

Crossrefs

Cf. A244477.

Programs

  • GAP
    a:=[1,1,1,1,2,5];; for n in [7..100] do a[n]:=a[a[n-3]]+a[n-a[n-2]]; od; a; # Muniru A Asiru, Jun 26 2018
  • Mathematica
    LinearRecurrence[{0,0,2,0,0,-1},{1,1,1,1,2,5,3,2,7,3,2,10},100] (* Harvey P. Dale, Apr 20 2022 *)
  • PARI
    a=vector(99); a[1]=a[2]=a[3]=a[4]=1;a[5]=2;a[6]=5;for(n=7, #a, a[n] = a[a[n-3]]+a[n-a[n-2]]); a
    
  • PARI
    Vec(x*(1 + x + x^2 - x^3 + 3*x^5 + 2*x^6 - x^7 - 2*x^8 - 2*x^9 + x^11) / ((1 - x)^2*(1 + x + x^2)^2) + O(x^80)) \\ Colin Barker, Jun 20 2018
    

Formula

From Colin Barker, Jun 20 2018: (Start)
G.f.: x*(1 + x + x^2 - x^3 + 3*x^5 + 2*x^6 - x^7 - 2*x^8 - 2*x^9 + x^11) / ((1 - x)^2*(1 + x + x^2)^2).
a(n) = 2*a(n-3) - a(n-6) for n>10.
(End)

A302551 a(n) = a(a(n-1)) + a(n-a(n-2)) with a(1) = a(2) = a(5) = 1, a(3) = a(6) = 2, a(4) = 6.

Original entry on oeis.org

1, 1, 2, 6, 1, 2, 3, 4, 8, 6, 4, 8, 12, 10, 8, 6, 10, 14, 18, 16, 8, 6, 10, 20, 24, 22, 8, 6, 10, 26, 30, 28, 8, 6, 10, 32, 36, 34, 8, 6, 10, 38, 42, 40, 8, 6, 10, 44, 48, 46, 8, 6, 10, 50, 54, 52, 8, 6, 10, 56, 60, 58, 8, 6, 10, 62, 66, 64, 8, 6, 10, 68, 72, 70, 8, 6, 10, 74, 78, 76, 8, 6, 10
Offset: 1

Views

Author

Altug Alkan, Jun 20 2018

Keywords

Crossrefs

Cf. A244477.

Programs

  • GAP
    a:=[1,1,2,6,1,2];; for n in [7..100] do a[n]:=a[a[n-1]]+a[n-a[n-2]]; od; a; # Muniru A Asiru, Jun 26 2018
  • PARI
    a=vector(99); a[1]=1;a[2]=1;a[3]=2;a[4]=6;a[5]=1;a[6]=2;for(n=7, #a, a[n] = a[a[n-1]]+a[n-a[n-2]]); a
    
  • PARI
    Vec(x*(1 + x^2 + 5*x^3 - 5*x^4 + 2*x^5 + 4*x^6 - 4*x^7 + 4*x^8 - 6*x^9 + 4*x^10 + 6*x^11 - 3*x^12 - 3*x^14 + 3*x^15 + 3*x^16 - 6*x^17 + 6*x^19 - 6*x^20) / ((1 - x)^2*(1 + x)^2*(1 - x + x^2)^2*(1 + x + x^2)) + O(x^80)) \\ Colin Barker, Jun 20 2018
    

Formula

a(6*k-3) = 8, a(6*k-2) = 6, a(6*k-1) = 10, a(6*k) = 6*k - 4, a(6*k+1) = 6*k, a(6*k + 2) = 6*k - 2 for k > 2.
From Colin Barker, Jun 20 2018: (Start)
G.f.: x*(1 + x^2 + 5*x^3 - 5*x^4 + 2*x^5 + 4*x^6 - 4*x^7 + 4*x^8 - 6*x^9 + 4*x^10 + 6*x^11 - 3*x^12 - 3*x^14 + 3*x^15 + 3*x^16 - 6*x^17 + 6*x^19 - 6*x^20) / ((1 - x)^2*(1 + x)^2*(1 - x + x^2)^2*(1 + x + x^2)).
a(n) = a(n-1) - a(n-3) + a(n-4) + a(n-6) - a(n-7) + a(n-9) - a(n-10) for n>13.
(End)
Previous Showing 21-30 of 37 results. Next