{
  "aliases": null,
  "backlinks": null,
  "body": "\n## Example\n\nHofstadter sequences are integer sequences defined by nested [[nonlinear recurrences|7C7FBZGERM]], in which earlier values decide which earlier terms are used.\n\n1. The *Hofstadter $Q$-sequence* is given by $Q(1) = Q(2) = 1$ and $Q(n) = Q(n - Q(n-1)) + Q(n - Q(n-2))$ for $n \u003e 2$. It begins $1, 1, 2, 3, 3, 4, 5, 5, 6, 6, 6, 8, \\dots$.\n2. The *Hofstadter $G$-sequence* is given by $G(0) = 0$ and $G(n) = n - G(G(n-1))$ for $n \\ge 1$. It begins $0, 1, 1, 2, 3, 3, 4, 4, 5, \\dots$.\n\nCheck for $Q$: $Q(3) = Q(2) + Q(2) = 2$, $Q(4) = Q(2) + Q(3) = 3$, $Q(5) = Q(2) + Q(3) = 3$, $Q(6) = Q(3) + Q(3) = 4$.\nCheck for $G$: $G(1) = 1 - G(0) = 1$, $G(2) = 2 - G(1) = 1$, $G(3) = 3 - G(1) = 2$, $G(4) = 4 - G(2) = 3$.\nThe $G$-sequence has the closed form $G(n) = \\lfloor (n+1)/\\varphi \\rfloor$, where $\\varphi$ is the [[golden ratio|0SC8T7548D]].\nThe $Q$-sequence behaves erratically, and it is not known whether it is defined for all $n$, that is, whether $n - Q(n-1) \\ge 1$ and $n - Q(n-2) \\ge 1$ always hold.\n\n## Explanations\n\n### L1 human\n\nThese sequences come from Douglas Hofstadter's book *Gödel, Escher, Bach*.\nIn an ordinary recurrence, you always look back a fixed number of steps.\nHere, the values of the sequence tell you how far back to look, which makes the rule self-referential.\nSome of these sequences turn out to be tame, like $G$, while others, like $Q$, look chaotic and are still not understood.\n",
  "commit": "ff8a40749dc16545e3d2fc637f6b0196e81d0bfa",
  "front": {
    "illustrates": [
      "7C7FBZGERM"
    ],
    "kind": "example",
    "msc": [
      "11B37",
      "39A05"
    ],
    "name": "Hofstadter sequences",
    "same_as": {
      "wikidata": "Q1623269",
      "wikipedia": "Hofstadter sequence"
    },
    "sources": [
      {
        "url": "https://en.wikipedia.org/wiki/Hofstadter_sequence"
      }
    ],
    "tag": "ZNT0P1M1D5"
  },
  "kind": "example",
  "link": "https://tamnd.github.io/math2/node/ZNT0P1M1D5/",
  "links": [
    {
      "field": "illustrates",
      "target": "7C7FBZGERM"
    }
  ],
  "markdown": "https://tamnd.github.io/math2/node/ZNT0P1M1D5.md",
  "msc": [
    "11B37",
    "39A05"
  ],
  "name": "Hofstadter sequences",
  "prov": null,
  "role": "",
  "source": "https://github.com/tamnd/math2/blob/main/nodes/ZNT/ZNT0P1M1D5.md",
  "status": null,
  "tag": "ZNT0P1M1D5",
  "uri": "m2://ZNT0P1M1D5",
  "url": "https://tamnd.github.io/math2/wiki/hofstadter-sequences/",
  "writing": {
    "tag": "ZNT0P1M1D5",
    "kind": "example",
    "level": "W0",
    "next": [
      {
        "what": "an inventory row",
        "note": "the row of the inventory that the node accounts for",
        "have": 0,
        "want": 1
      },
      {
        "what": "a source with a locator",
        "have": 0,
        "want": 1
      }
    ]
  }
}
