{
  "id": "fibonacci",
  "version": "34437026bda9",
  "status": "published",
  "name": "Fibonacci Calculator",
  "question": "What is the nth Fibonacci number?",
  "summary": "Finds the nth Fibonacci number F(n) exactly for n from 0 to 1,000, with the terms before it and the ratio of consecutive terms, which approaches the golden ratio.",
  "category": "math",
  "subcategory": "algebra",
  "url": "https://www.acalculator.org/math/fibonacci-calculator",
  "markdown": "https://www.acalculator.org/math/fibonacci-calculator.md",
  "kind": "function",
  "method": "F(0) = 0, F(1) = 1, F(n) = F(n − 1) + F(n − 2), added in exact whole numbers.",
  "assumptions": [
    "The sequence starts F(0) = 0, F(1) = 1, so F(1) = F(2) = 1 match OpenStax’s a₁ and a₂.",
    "n is a whole number from 0 to 1000."
  ],
  "inputs": {
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "type": "object",
    "properties": {
      "n": {
        "title": "Term number n",
        "description": "Which Fibonacci number to find, from F(0) = 0 to F(1000).",
        "type": "integer",
        "minimum": 0,
        "maximum": 1000
      }
    }
  },
  "outputs": {
    "value": {
      "label": "F(n)",
      "description": "The nth Fibonacci number, exactly.",
      "format": "text"
    },
    "digits": {
      "label": "Digits",
      "description": "How many digits F(n) has.",
      "format": "integer"
    },
    "ratio": {
      "label": "F(n) ÷ F(n − 1)",
      "description": "The ratio of the last two terms, rounded half up to 10 significant figures (from n = 2).",
      "format": "text"
    },
    "terms": {
      "label": "Terms",
      "description": "The terms up to F(n), at most the last 20.",
      "format": "text"
    }
  },
  "defaultAnswer": {
    "inputs": {
      "n": 10
    },
    "outputs": {
      "value": "55",
      "digits": 2,
      "ratio": "1.617647059",
      "terms": "F(0) to F(10): 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55"
    },
    "text": "F(10) = 55."
  },
  "examples": [
    {
      "given": {
        "n": 10
      },
      "expect": {
        "value": "55",
        "digits": 2,
        "ratio": "1.617647059",
        "terms": "F(0) to F(10): 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55"
      },
      "source": "OpenStax, Algebra and Trigonometry 2e, §13.1 Sequences and Their Notations (Fibonacci: a₁ = a₂ = 1, aₙ = aₙ₋₁ + aₙ₋₂; a₁₀ = 34 + 21 = 55), https://openstax.org/books/algebra-and-trigonometry-2e/pages/13-1-sequences-and-their-notations"
    },
    {
      "given": {
        "n": 50
      },
      "expect": {
        "value": "12,586,269,025",
        "digits": 11
      },
      "source": "Python 3 cross-check from the recurrence in content.mdx: F(50) = 12586269025"
    },
    {
      "given": {
        "n": 100
      },
      "expect": {
        "value": "354,224,848,179,261,915,075",
        "digits": 21,
        "ratio": "1.618033989"
      },
      "source": "Python 3 cross-check from the recurrence in content.mdx: F(100) = 354224848179261915075"
    },
    {
      "given": {
        "n": 0
      },
      "expect": {
        "value": "0",
        "digits": 1,
        "terms": "F(0) to F(0): 0"
      },
      "source": "content.mdx: F(0) = 0 by definition"
    }
  ],
  "sources": [
    "OpenStax, Algebra and Trigonometry 2e, §13.1 Sequences and Their Notations (the Fibonacci sequence: a₁ = 1, a₂ = 1, aₙ = aₙ₋₁ + aₙ₋₂ for n ≥ 3; 1, 1, 2, 3, 5, 8, 13, 21, 34, …; a₁₀ = 34 + 21 = 55). https://openstax.org/books/algebra-and-trigonometry-2e/pages/13-1-sequences-and-their-notations (retrieved 2026-10-05)"
  ],
  "related": [
    "golden-ratio",
    "sequence",
    "arithmetic-sequence",
    "geometric-sequence"
  ],
  "changelog": []
}
