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

A194081 Smallest m such that A005375(m) = n.

Original entry on oeis.org

0, 1, 3, 4, 5, 6, 8, 10, 11, 13, 14, 15, 17, 18, 19, 20, 22, 23, 24, 25, 27, 29, 30, 31, 32, 34, 36, 37, 39, 40, 41, 42, 44, 46, 47, 49, 50, 51, 53, 54, 55, 56, 58, 60, 61, 63, 64, 65, 67, 68, 69, 70, 72, 73, 74, 75, 77, 79, 80, 82, 83, 84, 86, 87, 88, 89
Offset: 0

Views

Author

Reinhard Zumkeller, Aug 17 2011

Keywords

Comments

A005375(a(n)) = n and A005375(m) <> n for m < a(n).

Programs

  • Haskell
    import Data.List (elemIndex)
    import Data.Maybe (fromJust)
    a194081 n = a194081_list !! n
    a194081_list = map (fromJust . (`elemIndex` a005375_list)) [0..]
  • Mathematica
    a[0] := 0; a[n_] := a[n] = a[n] = n - a[a[a[a[n - 1]]]]; Table[Select[Range[0, 199], a[#] == n &][[1]], {n, 0, 65}] (* Alonso del Arte, Aug 17 2011 *)

A372397 Numbers occurring exactly twice in Hofstadter G/H-like sequence H_4 (A005375).

Original entry on oeis.org

1, 5, 6, 8, 11, 15, 19, 20, 24, 25, 27, 31, 32, 34, 37, 41, 42, 44, 47, 51, 55, 56, 58, 61, 65, 69, 70, 74, 75, 77, 80, 84, 88, 89, 93, 94, 96, 100, 101, 103, 106, 110, 114, 115, 119, 120, 122, 126, 127, 129, 132, 136, 137, 139, 142, 146, 150, 151, 155, 156
Offset: 1

Views

Author

A.H.M. Smeets, Apr 29 2024

Keywords

Comments

Also first prepending column of the 4-Zeckendorf array (see Ericksen and Anderson).
N. J. A. Sloane observed already the relation between Hofstadter G/H-like sequences H_k and k-Zeckendorf arrays in May 2003, at least for k = 3 (see formula section and history of A005374). First observation most probably by Diego Torres, Nov 2002, relating the Hofstadter G/H-like sequences H_k with the k-Zeckendorf arrays and Lamé sequences of order k (see comments in A005375 and A005376).

Crossrefs

Numbers occurring exactly twice in Hofstadter G/H like sequence H_k: A000291 (k=2), A005374 (k=3), this sequence (k=4), A372398 (k=5).

Programs

  • Python
    def H(n,k):
        if n == 0:
            return 0
        else:
            i, x = 0, n-1
            while i < k:
                i, x = i+1, H(x,k)
            return n-x
    n, nn = 0, 0
    while n < 50:
        if nn == 0:
            Hno = H(nn,4)
        else:
            Hnn = H(nn,4)
            if Hnn == Hno:
                n += 1
                print(Hnn, end = ", ")
            Hno = Hnn
        nn += 1

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
    

A005374 Hofstadter H-sequence: a(n) = n - a(a(a(n-1))).

Original entry on oeis.org

0, 1, 1, 2, 3, 4, 4, 5, 5, 6, 7, 7, 8, 9, 10, 10, 11, 12, 13, 13, 14, 14, 15, 16, 17, 17, 18, 18, 19, 20, 20, 21, 22, 23, 23, 24, 24, 25, 26, 26, 27, 28, 29, 29, 30, 31, 32, 32, 33, 33, 34, 35, 35, 36, 37, 38, 38, 39, 40, 41, 41, 42, 42, 43, 44, 45, 45, 46, 46, 47, 48, 48, 49, 50
Offset: 0

Views

Author

Keywords

Comments

Rule for constructing the sequence: a(n) = An, where An denotes the Lamé antecessor to (or right shift of) n, which is found by replacing each Lm(i) in the Zeckendorffian expansion (obtained by repeatedly subtracting the largest Lamé number (A000930) you can until nothing remains) by Lm(i-1) (A1=1). For example: 58 = 41 + 13 + 4, so a(58)= 28 + 9 + 3 = 40.
From Albert Neumueller (albert.neu(AT)gmail.com), Sep 28 2006: (Start)
As is shown on page 137 of Goedel, Escher, Bach, a recursively built tree structure can be obtained from this sequence:
20.21..22..23.24.25.26.27.28
.\./.../.../...\./...\./../
..14.15..16....17....18..19
...\./.../..../.......\./
....10.11...12........13
.....\./.../........./
......7...8........9.
.......\./......./
........5......6
.........\.../
...........4
........../
.........3
......../
.......2
....\./
.....1
To construct the tree: node n is connected to the node a(n) below it:
...n
../
a(n)
For example:
...8
../
.5
since a(8) = 5. If the nodes of the tree are read from bottom-to-top, left-to-right, we obtain the natural numbers: 1, 2, 3, 4, 5, 6, ...
The tree has a recursive structure, since the following construct
....../
.....x
..../
...x
\./
.x
can be repeatedly added on top of its own ends, to construct the tree from its root: E.g.,
................../
.................x
................/
...............x
......../...\./
.......x.....x
....../...../
.....x.....x
..\./...../
...x.....x
....\.../
......x
(End)
From Pierre Letouzey, Feb 20 2025: (Start)
For all n >= 0, A005206(n) <= a(n) <= A005375(n), as proved in Letouzey-Li-Steiner link. Last equality A005206(n) = a(n) occurs at n = 12; last equality a(n) = A005375(n) occurs at n = 18.
For all n >= 0, |a(n)-c*n| < 0.996, where c is the real root of x^3 + x - 1 = 0, c = 0.682327803828019327369483739... Proved in Letouzey link. (End)
The bound for |a(n)-c*n| is improved to 0.862 in Shallit (2025). - Jeffrey Shallit, Mar 09 2025

References

  • D. R. Hofstadter, Goedel, Escher, Bach: an Eternal Golden Braid, Random House, 1980, p. 137.
  • N. J. A. Sloane and Simon Plouffe, The Encyclopedia of Integer Sequences, Academic Press, 1995 (includes this sequence).

Crossrefs

Programs

  • Haskell
    a005374 n = a005374_list !! n
    a005374_list = 0 : 1 : zipWith (-)
       [2..] (map (a005374 . a005374) $ tail a005374_list)
    -- Reinhard Zumkeller, Dec 17 2011
    
  • Maple
    A005374 := proc(n) option remember: if n<1 then 0 else n-A005374(A005374(A005374(n-1))) fi end: # Francisco Salinas (franciscodesalinas(AT)hotmail.com), Jan 06 2002
    H:=proc(n) option remember; if n=1 then 1 else n-H(H(H(n-1))); fi; end proc;
  • Mathematica
    a[n_]:= a[n]= n - a[a[a[n-1]]]; a[0] = 0; Table[a[n], {n, 0, 73}] (* Jean-François Alcover, Jul 28 2011 *)
  • PARI
    first(m)=my(v=vector(m));v[1]=1;for(i=2,m,v[i]=i-v[v[v[i-1]]]);concat([0],v) \\ Anders Hellström, Dec 07 2015
    
  • SageMath
    @CachedFunction # a = A005374
    def a(n): return 0 if (n==0) else n - a(a(a(n-1)))
    [a(n) for n in range(101)] # G. C. Greubel, Nov 14 2022

Formula

Conjecture: a(n) = floor(c*n) + 0 or 1, where c is the real root of x^3+x-1 = 0, c=0.682327803828019327369483739... - Benoit Cloitre, Nov 05 2002 [Proved by Letouzey, see Letouzey link. - Pierre Letouzey, Feb 20 2025], [Also proved in Shallit (2025). - Jeffrey Shallit, Mar 09 2025]
a(n) = A020942(n) - 2*A064105(n) + A064106(n) (e.g. for n = 30 we get 20 = 93 - 2*137 + 201), and a(n) = 2*A020942(n) - A064105(n) - A023443(n) (e.g. for n = 30 we get 20 = 2*93 - 137 - 29). [Corrected by N. J. A. Sloane, Apr 29 2024 at the suggestion of A.H.M. Smeets.]
Also: a(n) = a(n-1) + 1 if n-1 belongs to sequence A064105-A020942-A000012, a(n-1) otherwise.
Recurrence: a(n) = a(n-1) if n-1 belongs to sequence A020942, a(n-1) + 1 otherwise.
Recurrence for n>=3: a(n) = Lm(k-1) + a(n-Lm(k)), where Lm(n) denotes Lamé sequence A000930(n) (Lm(n) = Lm(n-1) + Lm(n-3)) and k is such that Lm(k)< n <= Lm(k+1). Special case: a(Lm(n)) = Lm(n-1) for n>=1.
For n > 0: a(A136495(n)) = n. - Reinhard Zumkeller, Dec 17 2011

Extensions

More terms from James Sellers, Jul 12 2000
Additional comments and formulas from Diego Torres (torresvillarroel(AT)hotmail.com), Nov 23 2002

A005376 a(n) = n - a(a(a(a(a(n-1))))).

Original entry on oeis.org

0, 1, 1, 2, 3, 4, 5, 6, 6, 7, 7, 8, 9, 9, 10, 11, 12, 12, 13, 14, 15, 16, 16, 17, 18, 19, 20, 21, 21, 22, 23, 24, 25, 26, 26, 27, 27, 28, 29, 30, 31, 32, 32, 33, 33, 34, 35, 35, 36, 37, 38, 39, 40, 40, 41, 41, 42, 43, 43, 44, 45, 46, 46, 47, 48, 49, 50, 51, 51, 52, 52, 53, 54, 54
Offset: 0

Views

Author

Keywords

Comments

Conjecture: a(n) is approximately c*n, where c is the real root of x^5+x-1 = 0, c=0.754877666246692760049508896... - Benoit Cloitre, Nov 05 2002
Rule for n-th term: a(n) = An, where An denotes the Lamé antecedent to (or right shift of) n, which is found by replacing each Lm(i) (Lm(n) = Lm(n-1) + Lm(n-5): A003520) in the Zeckendorffian expansion (obtained by repeatedly subtracting the largest Lamé number you can until nothing remains) with Lm(i-1) (A1=1). For example: 58 = 45 + 11 + 2, so a(58) = 34 + 8 + 1 = 43. - Diego Torres (torresvillarroel(AT)hotmail.com), Nov 24 2002
From Pierre Letouzey, Mar 06 2025: (Start)
For all n >= 0, A005375(n) <= a(n) <= A100721(n) as proved in Letouzey-Li-Steiner link. Last equality A005375(n) = a(n) for n = 25; last equality a(n) = A100721(n) for n = 33.
a(n) = c*n + O(ln(n)), with c conjectured by Benoit Cloitre above; see Letouzey link and Dilcher 1993. (End)

References

  • Karl Dilcher, On a class of iterative recurrence relations, in G. E. Bergum, A. N. Philippou, and A. F. Horadam, editors, Applications of Fibonacci Numbers, vol. 5, p. 143-158, Springer, 1993.
  • Douglas R. Hofstadter, "Goedel, Escher, Bach", p. 137.
  • N. J. A. Sloane and Simon Plouffe, The Encyclopedia of Integer Sequences, Academic Press, 1995 (includes this sequence).

Crossrefs

Programs

  • Maple
    H:=proc(n) option remember; if n=1 then 1 else n-H(H(H(H(H(n-1))))); fi; end proc;
  • Mathematica
    a[n_]:= a[n]= If[n<1, 0, n -a[a[a[a[a[n-1]]]]]];
    Table[a[n], {n, 0, 100}] (* G. C. Greubel, Nov 16 2022 *)
  • SageMath
    @CachedFunction # a = A005376
    def a(n): return 0 if (n==0) else n - a(a(a(a(a(n-1)))))
    [a(n) for n in range(101)] # G. C. Greubel, Nov 16 2022

Formula

a(n + a(a(a(a(n))))) = n (proved in Letouzey-Li-Steiner link). - Pierre Letouzey, Mar 06 2025

Extensions

More terms from James Sellers, Jul 12 2000

A100721 a(n) = n - a(a(a(a(a(a(n-1)))))), a(0)=0.

Original entry on oeis.org

0, 1, 1, 2, 3, 4, 5, 6, 7, 7, 8, 8, 9, 10, 10, 11, 12, 13, 13, 14, 15, 16, 17, 17, 18, 19, 20, 21, 22, 22, 23, 24, 25, 26, 27, 28, 28, 29, 30, 31, 32, 33, 34, 34, 35, 35, 36, 37, 38, 39, 40, 41, 41, 42, 42, 43, 44, 44, 45, 46, 47, 48, 49, 50, 50, 51, 51, 52, 53, 53, 54, 55, 56, 56, 57, 58, 59
Offset: 0

Views

Author

N. J. A. Sloane, Dec 12 2004

Keywords

Comments

From Pierre Letouzey, Mar 06 2025: (Start)
For all n >= 0, A005376(n) <= a(n) as proved in Letouzey-Li-Steiner link. Last equality a(n) = A005376(n) for n = 33. Moreover a(n) <= b(n) for all sequences b also defined by b(0)=0 and then b(n)=n-b(...b(n-1)...) with more than 6 nested recursive calls.
a(n) = c*n + O(n^d), where c is the real root of x^6+x-1 = 0, c=0.7780895986786012... and d=0.1287... Proved in Letouzey link. See also Dilcher 1993. (End)

References

  • Karl Dilcher, On a class of iterative recurrence relations, in G. E. Bergum, A. N. Philippou, and A. F. Horadam, editors, Applications of Fibonacci Numbers, vol. 5, p. 143-158, Springer, 1993.

Crossrefs

Programs

  • Maple
    H:=proc(n) option remember; if n=0 then 0 else n-H(H(H(H(H(H(n-1)))))); fi; end proc;
  • Mathematica
    a[0]= 0; a[n_]:= a[n]= n - a[a[a[a[a[a[n-1]]]]]]; Table[ a[n], {n, 75}] (* Robert G. Wilson v, Dec 16 2004 *)
  • SageMath
    @CachedFunction # a = A100721
    def a(n): return 0 if (n==0) else n - a(a(a(a(a(a(n-1))))))
    [a(n) for n in range(1,100)] # G. C. Greubel, Nov 16 2022

Formula

a(n + a(a(a(a(a(n)))))) = n (proved in Letouzey-Li-Steiner link). - Pierre Letouzey, Mar 06 2025

Extensions

a(0)=0 inserted by Pierre Letouzey, Mar 07 2025

A372398 Numbers occurring exactly twice in Hofstadter G/H-like sequence H_5 (A005376).

Original entry on oeis.org

1, 6, 7, 9, 12, 16, 21, 26, 27, 32, 33, 35, 40, 41, 43, 46, 51, 52, 54, 57, 61, 66, 67, 69, 72, 76, 81, 86, 87, 89, 92, 96, 101, 106, 107, 112, 113, 115, 118, 122, 127, 132, 133, 138, 139, 141, 146, 147, 149, 152, 156, 161, 166, 167, 172, 173, 175, 180, 181
Offset: 1

Views

Author

A.H.M. Smeets, Apr 29 2024

Keywords

Comments

Also first prepending column of the 5-Zeckendorf array (see Ericksen and Anderson).
N. J. A. Sloane observed already the relation between Hofstadter G/H-like sequences H_k and k-Zeckendorf arrays in May 2003, at least for k = 3 (see formula section and history of A005374). First observation most probably by Diego Torres, Nov 2002, relating the Hofstadter G/H-like sequences H_k with the k-Zeckendorf arrays and Lamé sequences of order k (see comments in A005375 and A005376).

Crossrefs

Numbers occurring exactly twice in Hofstadter G/H like sequence H_k: A000291 (k=2), A005374 (k=3), A372397 (k=4), this sequence (k=5).

Programs

  • Python
    def H(n,k):
        if n == 0:
            return 0
        else:
            i, x = 0, n-1
            while i < k:
                i, x = i+1, H(x,k)
            return n-x
    n, nn = 0, 0
    while n < 59:
        if nn == 0:
            Hno = H(nn,5)
        else:
            Hnn = H(nn,5)
            if Hnn == Hno:
                n += 1
                print(Hnn, end = ", ")
            Hno = Hnn
        nn += 1
Showing 1-7 of 7 results.