A005206 Hofstadter G-sequence: a(0) = 0; a(n) = n - a(a(n-1)) for n > 0.
0, 1, 1, 2, 3, 3, 4, 4, 5, 6, 6, 7, 8, 8, 9, 9, 10, 11, 11, 12, 12, 13, 14, 14, 15, 16, 16, 17, 17, 18, 19, 19, 20, 21, 21, 22, 22, 23, 24, 24, 25, 25, 26, 27, 27, 28, 29, 29, 30, 30, 31, 32, 32, 33, 33, 34, 35, 35, 36, 37, 37, 38, 38, 39, 40, 40, 41, 42, 42, 43, 43, 44, 45, 45, 46, 46, 47
Offset: 0
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).
Links
- N. J. A. Sloane and T. D. Noe, Table of n, a(n) for n = 0..20000 (the first 1000 terms were found by T. D. Noe)
- L. Carlitz, Fibonacci Representations, Fibonacci Quarterly, volume 6, number 4, October 1968, pages 193-220. a(n) = e(n) at equation 1.10 or 2.11 and see equation 3.8 recurrence.
- M. Celaya and F. Ruskey, Morphic Words and Nested Recurrence Relations, arXiv preprint arXiv:1307.0153 [math.CO], 2013.
- M. Celaya and F. Ruskey, Another Property of Only the Golden Ratio, American Mathematical Monthly, Problem 11651, solutions volume 121, number 6, June-July 2014, pages 549-556.
- F. Michel Dekking, Morphisms, Symbolic Sequences, and Their Standard Forms, Journal of Integer Sequences, Vol. 19 (2016), Article 16.1.1.
- F. M. Dekking, On Hofstadter's G-sequence, Journal of Integer Sequences 26 (2023), Article 23.9.2, 1-11.
- Larry Ericksen and Peter G. Anderson, Patterns in differences between rows in k-Zeckendorf arrays, The Fibonacci Quarterly, Vol. 50, No. 1 (February 2012), pp. 11-18.
- D. Gault and M. Clint, "Curiouser and curiouser" said Alice. Further reflections on an interesting recursive function, Internat. J. Computer Math., 26 (1988), 35-43. Also annotated scanned copy.
- Martin Griffiths, A formula for an infinite family of Fibonacci-word sequences, Fib. Q., 56 (2018), 75-80.
- H. W. Gould, J. B. Kim and V. E. Hoggatt, Jr., Sequences associated with t-ary coding of Fibonacci's rabbits, Fib. Quart., 15 (1977), 311-318.
- Vincent Granville and Jean-Paul Rasson, A strange recursive relation, J. Number Theory 30 (1988), no. 2, 238--241. MR0961919(89j:11014).
- J. Grytczuk, Another variation on Conway's recursive sequence, Discr. Math. 282 (2004), 149-161.
- Nick Hobson, Python program for this sequence
- D. R. Hofstadter, Eta-Lore [Cached copy, with permission]
- D. R. Hofstadter, Pi-Mu Sequences [Cached copy, with permission]
- D. R. Hofstadter and N. J. A. Sloane, Correspondence, 1977 and 1991
- The IMO Compendium, Problem 1, 45th Czech and Slovak Mathematical Olympiad 1996.
- Clark Kimberling and K. B. Stolarsky, Slow Beatty sequences, devious convergence, and partitional divergence, Amer. Math. Monthly, 123 (No. 2, 2016), 267-273.
- Pierre Letouzey, Hofstadter's problem for curious readers, Technical Report, 2015.
- Pierre Letouzey, S. Li and W. Steiner, Pointwise order of generalized Hofstadter functions G,H and beyond, arXiv:2410.00529 [cs.DM], 2024.
- Pierre Letouzey, Generalized Hofstadter functions G,H and beyond: numeration systems and discrepancy arXiv:2502.12615 [cs.DM], 2025.
- Mustazee Rahman, A Combinatorial interpretation of Hofstadter's G-sequence, arXiv:1105.1718 [math.CO], 2011-2013.
- B. Schoenmakers, A tight lower bound for top-down skew heaps, Information Processing Letters, 61(5): 279-284, 14 March 1997.
- Torsten Sillke, Floor Recurrences
- Th. Stoll, On Hofstadter's married functions, Fib. Q., 46/47 (2008/2009), 62-67. - _N. J. A. Sloane_, May 30 2009
- Eric Weisstein's World of Mathematics, Hofstadter G-Sequence
- Wikipedia, Hofstadter sequence
- Index entries for Hofstadter-type sequences
- Index entries for sequences from "Goedel, Escher, Bach"
- Index to sequences related to Olympiads.
Crossrefs
Programs
-
Haskell
a005206 n = a005206_list !! n a005206_list = 0 : zipWith (-) [1..] (map a005206 a005206_list) -- Reinhard Zumkeller, Feb 02 2012, Aug 07 2011
-
Haskell
a005206 = sum . zipWith (*) a000045_list . a213676_row . a000201 . (+ 1) -- Reinhard Zumkeller, Mar 10 2013
-
Magma
[Floor((n+1)*(1+Sqrt(5))/2)-n-1: n in [0..80]]; // Vincenzo Librandi, Nov 19 2016
-
Maple
H:=proc(n) option remember; if n=0 then 0 elif n=1 then 1 else n-H(H(n-1)); fi; end proc: seq(H(n),n=0..76);
-
Mathematica
a[0] = 0; a[n_] := a[n] = n - a[a[n - 1]]; Array[a, 77, 0] (* Second program: *) Fold[Append[#1, #2 - #1[[#1[[#2]] + 1 ]] ] &, {0}, Range@ 76] (* Michael De Vlieger, Nov 13 2017 *)
-
PARI
first(n)=my(v=vector(n)); v[1]=1; for(k=2,n, v[k]=k-v[v[k-1]]); concat(0,v) \\ Charles R Greathouse IV, Sep 02 2015
-
Python
from math import isqrt def A005206(n): return (n+1+isqrt(5*(n+1)**2)>>1)-n-1 # Chai Wah Wu, Aug 09 2022
Formula
a(n) = floor((n+1)*tau) - n - 1 = A000201(n+1)-n-1, where tau = (1+sqrt(5))/2; or a(n) = floor(sigma*(n+1)) where sigma = (sqrt(5)-1)/2.
a(0)=0, a(1)=1, a(n) = n - a(floor(n/tau)). - Benoit Cloitre, Nov 27 2002
a(n) = A019446(n) - 1. - Reinhard Zumkeller, Feb 02 2012
a(n) = n - A060144(n+1). - Reinhard Zumkeller, Apr 07 2012
a(n) = Sum_{k=1..A072649(m)} A000045(m)*A213676(m,k): m=A000201(n+1). - Reinhard Zumkeller, Mar 10 2013
From Pierre Letouzey, Sep 09 2015: (Start)
a(n + a(n)) = n.
a(n) + a(a(n+1) - 1) = n.
a(0) = 0, a(n+1) = a(n) + d(n) and d(0) = 1, d(n+1)=1-d(n)*d(a(n)). (End)
a(n) = A293688(n)/(n+1) for n >= 0 (conjectured). - Enrique Navarrete, Oct 15 2017
A generalization of Diego Torres's 2002 comment as a formula: if n = Sum_{i in S} A000045(i+1), where S is a set of positive integers, then a(n) = Sum_{i in S} A000045(i). - Peter Munn, Sep 28 2022
Conjectures from Chunqing Liu, Aug 01 2023: (Start)
a(A000201(n)-1) = n-1.
Extensions
a(0) = 0 added in the Name by Bernard Schott, Apr 23 2022
Comments