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

A286569 Restricted growth sequence transform of "Hofstadter chaotic heart", A284019 (= A004001(n) - A005185(n)).

Original entry on oeis.org

1, 1, 1, 2, 1, 1, 2, 2, 2, 1, 3, 2, 1, 1, 4, 2, 2, 2, 1, 1, 1, 3, 5, 4, 3, 3, 2, 1, 1, 1, 6, 2, 1, 4, 4, 3, 3, 2, 3, 3, 3, 3, 3, 5, 5, 7, 7, 8, 9, 9, 2, 5, 9, 1, 3, 7, 2, 3, 1, 1, 1, 1, 10, 2, 5, 6, 1, 7, 4, 4, 3, 3, 1, 5, 5, 7, 3, 9, 9, 5, 5, 9, 9, 5, 9, 7, 5, 7, 11, 7, 9, 11, 11, 12, 12, 13, 14, 9, 5, 3, 15, 7, 9, 16, 4, 12, 11, 5, 1, 16, 3, 3, 17, 1, 6, 18
Offset: 1

Views

Author

Antti Karttunen, May 18 2017

Keywords

Examples

			We start by setting a(1) = 1 for A284019(1) = 0. Then after, whenever A284019(k) is equal to some A284019(m) with m < k, we set a(k) = a(m). Otherwise (when the value is a new one, not encountered before), we allot for a(k) the least natural number not present among a(1) .. a(k-1).
For n=2, as A284019(2) = 0, which was already present at A284019(1), we set a(2) = a(1) = 1.
For n=3, as A284019(3) = 0, which was already present at n=1, we set a(3) = a(1) = 1.
For n=4, as A284019(4) = -1, which is a new value not encountered before, we set a(4) = 1 + max(a(1),a(2),a(3)) = 2.
For n=5, as A284019(5) = 0, which was already present at n=1, we set a(5) = a(1) = 1.
For n=7, as A284019(7) = -1, which was already present at n=4, we set a(7) = a(4) = 2.
For n=11, as A284019(11) = 1, which is a new value not encountered before (sign matters here), we set a(11) = 1 + max(a(1),..,a(10)) = 3.
		

Crossrefs

A284606 a(n) = (-1)^n * A284019(n).

Original entry on oeis.org

0, 0, 0, -1, 0, 0, 1, -1, 1, 0, -1, -1, 0, 0, 2, -1, 1, -1, 0, 0, 0, 1, -2, -2, -1, 1, 1, 0, 0, 0, 4, -1, 0, -2, 2, 1, -1, -1, -1, 1, -1, 1, -1, 2, -2, 3, -3, -5, -4, 4, 1, 2, -4, 0, -1, 3, 1, 1, 0, 0, 0, 0, 8, -1, -2, -4, 0, 3, 2, -2, -1, 1, 0, 2, -2, 3, -1, 4, -4
Offset: 1

Views

Author

Altug Alkan, Mar 30 2017

Keywords

Examples

			a(4) = -1 since a(4) = (-1)^4 * (A004001(4) - A005185(4)) = 2 - 3 = -1
		

Crossrefs

Programs

  • Maple
    A005185:= proc(n) option remember; procname(n-procname(n-1)) +procname(n-procname(n-2)) end proc:
    A005185(1):= 1: A005185(2):= 1:
    A004001:= proc(n) option remember; procname(procname(n-1)) +procname(n-procname(n-1)) end proc:
    A004001(1):= 1: A004001(2):= 1:
    A284606:= map((-1)^i * (A004001 - A005185), [$1..1000]):
    seq(A284606[i], i=1..1000); # Altug Alkan, Apr 01 2017
  • Mathematica
    a[n_] := a[n] = If[n <= 2, 1, a[a[n - 1]] + a[n - a[n - 1]]]; b[1] = b[2] = 1; b[n_] := b[n] = b[n - b[n - 1]] + b[n - b[n - 2]]; Table[(-1)^n*(a@ n - b@ n), {n, 87}] (* Michael De Vlieger, Apr 02 2017, after Robert G. Wilson v at A004001 *)
  • PARI
    q=vector(10000); h=vector(10000); q[1]=q[2]=1; for(n=3, #q, q[n]=q[n-q[n-1]]+q[n-q[n-2]]); h[1]=h[2]=1; for(n=3, #h, h[n]=h[h[n-1]]+h[n-h[n-1]]); vector(10000, n, (-1)^n*(h[n]-q[n]))

Formula

a(n) = (-1)^n * (A004001(n) - A005185(n)).

A005185 Hofstadter Q-sequence: a(1) = a(2) = 1; a(n) = a(n-a(n-1)) + a(n-a(n-2)) for n > 2.

Original entry on oeis.org

1, 1, 2, 3, 3, 4, 5, 5, 6, 6, 6, 8, 8, 8, 10, 9, 10, 11, 11, 12, 12, 12, 12, 16, 14, 14, 16, 16, 16, 16, 20, 17, 17, 20, 21, 19, 20, 22, 21, 22, 23, 23, 24, 24, 24, 24, 24, 32, 24, 25, 30, 28, 26, 30, 30, 28, 32, 30, 32, 32, 32, 32, 40, 33, 31, 38, 35, 33, 39, 40, 37, 38, 40, 39
Offset: 1

Views

Author

Simon Plouffe and N. J. A. Sloane, May 20 1991

Keywords

Comments

Rate of growth is not known. In fact it is not even known if this sequence is defined for all positive n.
Roman Pearce, Aug 29 2014, has computed that a(n) exists for n <= 10^10. - N. J. A. Sloane
a(n) exists for n <= 3*10^10. - M. Eric Carr, Jul 02 2023

Examples

			a(18) = 11 because a(17) is 10 and a(16) is 9, so we take a(18 - 10) + a(18 - 9) = a(8) + a(9) = 5 + 6 = 11.
		

References

  • B. W. Conolly, "Meta-Fibonacci sequences," in S. Vajda, editor, Fibonacci and Lucas Numbers and the Golden Section. Halstead Press, NY, 1989, pp. 127-138.
  • R. K. Guy, Unsolved Problems in Number Theory, Sect. E31.
  • D. R. Hofstadter, Goedel, Escher, Bach: an Eternal Golden Braid, Random House, 1980, p. 138.
  • N. J. A. Sloane and Simon Plouffe, The Encyclopedia of Integer Sequences, Academic Press, 1995 (includes this sequence).
  • S. Vajda, Fibonacci and Lucas Numbers and the Golden Section, Wiley, 1989, see p. 129.
  • S. Wolfram, A New Kind of Science, Wolfram Media, 2002; p. 129.

Crossrefs

Cf. A081827 (first differences).
Cf. A226244, A226245 (record values and where they occur).
See A244477 for a different start.

Programs

  • C
    #include 
    #define LIM 20
    int Qa[LIM];
    int Q(int n){if (n==1 || n==2){return 1;} else{return Qa[n-Qa[n-1]]+Qa[n-Qa[n-2]];}}
    int main(){int i;printf("n\tQ\n");for(i=1; iGonzalo Ciruelos, Aug 01 2013
    
  • Haskell
    a005185 n = a005185_list !! (n-1)
    a005185_list = 1 : 1 : zipWith (+)
       (map a005185 $ zipWith (-) [3..] a005185_list)
       (map a005185 $ zipWith (-) [3..] $ tail a005185_list)
    -- Reinhard Zumkeller, Jun 02 2013, Sep 15 2011
    
  • Magma
    I:=[1,1]; [n le 2 select I[n] else Self(n-Self(n-1))+Self(n-Self(n-2)): n in [1..90]]; // Vincenzo Librandi, Aug 08 2014
    
  • Maple
    A005185 := proc(n) option remember;
        if n<=2 then 1
        elif n > procname(n-1) and n > procname(n-2) then
            RETURN(procname(n-procname(n-1))+procname(n-procname(n-2)));
        else
            ERROR(" died at n= ", n);
        fi; end proc;
    # More generally, the following defines the Hofstadter-Huber sequence Q(r,s) - N. J. A. Sloane, Apr 15 2014
    r:=1; s:=2;
    a:=proc(n) option remember; global r,s;
    if n <= s then  1
    else
        if (a(n-r) <= n) and (a(n-s) <= n) then
        a(n-a(n-r))+a(n-a(n-s));
        else lprint("died with n =",n); return (-1);
        fi; fi; end;
    [seq(a(n), n=1..100)];
  • Mathematica
    a[1]=a[2]=1; a[n_]:= a[n]= a[n -a[n-1]] + a[n -a[n-2]]; Table[ a[n], {n,70}]
  • MuPAD
    q:=proc(n) option remember; begin if n<=2 then 1 else q(n-q(n-1))+q(n-q(n-2)) end_if; end_proc: q(i)$i=1..100; // Zerinvary Lajos, Apr 03 2007
    
  • PARI
    {a(n)= local(A); if(n<1, 0, A=vector(n,k,1); for(k=3, n, A[k]= A[k-A[k-1]]+ A[k-A[k-2]]); A[n])} /* Michael Somos, Jul 16 2007 */
    
  • Python
    from functools import lru_cache
    @lru_cache(maxsize=None)
    def a(n):
        if n < 3: return 1
        return a(n - a(n-1)) + a(n - a(n-2))
    print([a(n) for n in range(1, 75)]) # Michael S. Branicky, Jul 26 2021
  • Sage
    @CachedFunction
    def a(n):
        if (n<3): return 1
        else: return a(n -a(n-1)) + a(n -a(n-2))
    [a(n) for n in (1..70)] # G. C. Greubel, Feb 13 2020
    
  • Scheme
    (define q (lambda (n) (cond ( (eqv? n 0) 1) ( (eqv? n 1) 1) ( #t (+ (q (- n (q (- n 1)))) (q (- n (q (- n 2)))))))))
    
  • Scheme
    ;; An implementation of memoization-macro definec can be found for example in: http://oeis.org/wiki/Memoization
    (definec (A005185 n) (if (<= n 2) 1 (+ (A005185 (- n (A005185 (- n 1)))) (A005185 (- n (A005185 (- n 2)))))))
    ;; Antti Karttunen, Mar 22 2017
    

A286560 Compound filter (summands of A004001 & summands of A005185): a(n) = P(A286541(n), A286559(n)), where P(n,k) is sequence A000027 used as a pairing function, with a(1) = a(2) = 0.

Original entry on oeis.org

0, 0, 1, 2, 5, 41, 71, 71, 198, 313, 484, 922, 1153, 1201, 2105, 1565, 2588, 4046, 5001, 7443, 7443, 8851, 10671, 19589, 16570, 16935, 22254, 25313, 25313, 25313, 42891, 28793, 32768, 52795, 65504, 59178, 73355, 89033, 88632, 107660, 129045, 129045, 153471, 167646, 167646, 182446, 182446, 336130, 197244, 233297, 330472, 307358, 270167, 355325, 378466, 332156
Offset: 1

Views

Author

Antti Karttunen, May 18 2017

Keywords

Crossrefs

Programs

Formula

a(1) = a(2) = 0, for n > 2, a(n) = (1/2)*(2 + ((A286541(n)+A286559(n))^2) - A286541(n) - 3*A286559(n)).

A087740 a(n) = 1 + abs(A004001(A005185(n)) - A005185(A004001(n))).

Original entry on oeis.org

1, 1, 1, 2, 1, 2, 1, 1, 2, 1, 2, 2, 2, 2, 2, 1, 1, 2, 2, 2, 2, 2, 2, 1, 3, 3, 3, 2, 2, 2, 4, 1, 2, 2, 2, 2, 1, 2, 1, 2, 3, 3, 1, 1, 1, 3, 3, 1, 3, 2, 1, 1, 2, 1, 5, 5, 5, 5, 2, 2, 2, 2, 7, 1, 2, 2, 3, 3, 3, 2, 2, 1, 2, 2, 1, 2, 1, 2, 1, 2, 3, 2, 2, 6, 7, 7, 4, 3, 4, 4, 2, 2, 2, 4, 4, 3, 7, 3, 3, 2, 6, 3, 1, 2, 3, 1, 3, 2, 1, 3, 1, 1, 3, 1, 3, 2, 9, 5, 9, 10
Offset: 1

Views

Author

Roger L. Bagula, Oct 01 2003

Keywords

Comments

A "commutator" between the Hofstadter A005185 sequence and the Conway-Hofstadter A004001 sequence.

Crossrefs

Cf. A004001, A005185, A284019 (compare the scatter plots).
Cf. also A286560.

Programs

  • Mathematica
    Conway[n_Integer?Positive] := Conway[n] =Conway[Conway[n-1]] + Conway[n - Conway[n-1]] Conway[1] = Conway[2] = 1 Hofstadter[n_Integer?Positive] := Hofstadter[n] = Hofstadter[n - Hofstadter[n-1]] + Hofstadter[n - Hofstadter[n-2]] Hofstadter[1] = Hofstadter[2] = 1 digits=200 a=Table[1+Abs[Conway[Hofstadter[n]]-Hofstadter[Conway[n]]], {n, 1, digits}]
  • Scheme
    (define (A087740 n) (+ 1 (abs (- (A004001 (A005185 n)) (A005185 (A004001 n)))))) ;; Scheme-code for A004001 and A005185 given under those entries.

Extensions

Data section extended to 120 terms by Antti Karttunen, May 22 2017

A302780 Restricted growth sequence transform of 4-tuple [H(H(n-1)), H(n-H(n-1)), Q(n-Q(n-1)), Q(n-Q(n-2))] where H = A004001 and Q = A005185.

Original entry on oeis.org

1, 1, 2, 3, 4, 5, 6, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 18, 19, 20, 21, 22, 23, 24, 25, 25, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 36, 37, 38, 38, 39, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 47, 50, 50, 50, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 79, 80, 80
Offset: 1

Views

Author

Antti Karttunen, Apr 27 2018

Keywords

Comments

Restricted growth sequence transform of A286560: a filter sequence which includes both the summands of A004001 and the summands of A005185.
For all i, j: a(i) = a(j) => b(i) = b(j), where b is a sequence like A087740, A284019, A286569 or A302779.
For n > 1000 the duplicates get rare. In range [1000, 65536] there are only three cases: a(1353) = a(1354) = 1319, a(39361) = a(39362) = 39326, and a(46695) = a(46696) = 46659.

Crossrefs

Programs

  • PARI
    up_to = 65537;
    first_n_of_A004001(n) = { my(v=vector(n)); v[1]=v[2]=1; for(k=3, n, v[k]=v[v[k-1]]+v[k-v[k-1]]); (v); }; \\ Charles R Greathouse IV, Feb 26 2017
    v004001 = first_n_of_A004001(up_to);
    A004001(n) = v004001[n];
    first_n_of_A005185(n) = { my(v=vector(n)); v[1]=v[2]=1; for(k=3, n, v[k]=v[k-v[k-1]]+v[k-v[k-2]]); (v); }; \\
    v005185 = first_n_of_A005185(up_to);
    A005185(n) = v005185[n];
    Aux302780(n) = if(n<3,0,[A004001(A004001(n-1)), A004001(n-A004001(n-1)), A005185(n-A005185(n-1)), A005185(n-A005185(n-2))]);
    rgs_transform(invec) = { my(om = Map(), outvec = vector(length(invec)), u=1); for(i=1, length(invec), if(mapisdefined(om,invec[i]), my(pp = mapget(om, invec[i])); outvec[i] = outvec[pp] , mapput(om,invec[i],i); outvec[i] = u; u++ )); outvec; };
    write_to_bfile(start_offset,vec,bfilename) = { for(n=1, length(vec), write(bfilename, (n+start_offset)-1, " ", vec[n])); }
    write_to_bfile(1,rgs_transform(vector(up_to,n,Aux302780(n))),"b302780.txt");
Showing 1-6 of 6 results.