{
  "id": "sequence",
  "version": "0c78503e348a",
  "status": "published",
  "name": "Sequence Calculator",
  "question": "What is my sequence's nth term?",
  "summary": "Finds the nth term and the sum of the first n terms of an arithmetic or geometric sequence, lists the first terms, and writes its explicit and recursive formulas.",
  "category": "math",
  "subcategory": "algebra",
  "url": "https://www.acalculator.org/math/sequence-calculator",
  "markdown": "https://www.acalculator.org/math/sequence-calculator.md",
  "kind": "function",
  "method": "Arithmetic: aₙ = a₁ + (n − 1)d and Sₙ = n(a₁ + aₙ)/2. Geometric: aₙ = a₁ × r^(n − 1) and Sₙ = a₁(1 − rⁿ)/(1 − r) (n × a₁ when r = 1); for −1 < r < 1 the sum to infinity is a₁/(1 − r).",
  "assumptions": [
    "Terms are numbered from 1; the first term is a₁.",
    "The numbers are read as the exact decimals typed and the formulas are worked out in exact fractions; each result is then the nearest 64-bit float.",
    "A term or sum beyond about 1.8 × 10^308 has no answer."
  ],
  "inputs": {
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "type": "object",
    "properties": {
      "type": {
        "title": "Sequence",
        "description": "Arithmetic adds the same difference each step; geometric multiplies by the same ratio.",
        "type": "string",
        "enum": [
          "arithmetic",
          "geometric"
        ]
      },
      "a": {
        "title": "First term (a₁)",
        "description": "The first term of the sequence.",
        "type": "number",
        "minimum": -1000000000,
        "maximum": 1000000000
      },
      "d": {
        "title": "Common difference (d)",
        "description": "What is added to each term to get the next one.",
        "type": "number",
        "minimum": -1000000000,
        "maximum": 1000000000
      },
      "r": {
        "title": "Common ratio (r)",
        "description": "What each term is multiplied by to get the next one.",
        "type": "number",
        "minimum": -1000,
        "maximum": 1000
      },
      "n": {
        "title": "Term number (n)",
        "description": "Which term to find, and how many terms to add up, from 1 to 10,000.",
        "type": "integer",
        "minimum": 1,
        "maximum": 10000
      }
    }
  },
  "outputs": {
    "nth": {
      "label": "nth term (aₙ)",
      "description": "The value of term number n.",
      "format": "number"
    },
    "sum": {
      "label": "Sum of the first n terms (Sₙ)",
      "description": "a₁ + a₂ + … + aₙ.",
      "format": "number"
    },
    "infinite": {
      "label": "Sum to infinity",
      "description": "For a geometric sequence with −1 < r < 1, the limit of the sums: a₁ ÷ (1 − r).",
      "format": "number"
    },
    "terms": {
      "label": "First terms",
      "description": "The first terms of the sequence, up to 10 of them.",
      "format": "text"
    },
    "explicit": {
      "label": "Explicit formula",
      "description": "A formula for term number n on its own.",
      "format": "text"
    },
    "recursive": {
      "label": "Recursive formula",
      "description": "The first term, and how each term follows from the one before.",
      "format": "text"
    }
  },
  "defaultAnswer": {
    "inputs": {
      "type": "arithmetic",
      "a": 2,
      "d": 3,
      "r": 2,
      "n": 10
    },
    "outputs": {
      "nth": 29,
      "sum": 155,
      "terms": "2, 5, 8, 11, 14, 17, 20, 23, 26, 29",
      "explicit": "a_n = 2 + 3(n - 1)",
      "recursive": "a_1 = 2, a_n = a_(n - 1) + 3"
    },
    "text": "Term 10 is 29, and the sum of terms 1 to 10 is 155."
  },
  "examples": [
    {
      "given": {
        "type": "arithmetic",
        "a": 2,
        "d": 3,
        "n": 10
      },
      "expect": {
        "nth": 29,
        "sum": 155,
        "terms": "2, 5, 8, 11, 14, 17, 20, 23, 26, 29",
        "explicit": "a_n = 2 + 3(n - 1)",
        "recursive": "a_1 = 2, a_n = a_(n - 1) + 3"
      },
      "source": "hand calculation in content.mdx: a₁₀ = 2 + 9 × 3 = 29, S₁₀ = 10 × (2 + 29)/2 = 155; formulas from OpenStax College Algebra 2e, section 9.2: https://openstax.org/books/college-algebra-2e/pages/9-2-arithmetic-sequences"
    },
    {
      "given": {
        "type": "geometric",
        "a": 3,
        "r": 2,
        "n": 8
      },
      "expect": {
        "nth": 384,
        "sum": 765,
        "terms": "3, 6, 12, 24, 48, 96, 192, 384",
        "explicit": "a_n = 3 × 2^(n - 1)"
      },
      "source": "hand calculation in content.mdx: a₈ = 3 × 2⁷ = 384, S₈ = 3 × (2⁸ − 1)/(2 − 1) = 765"
    },
    {
      "given": {
        "type": "geometric",
        "a": 1,
        "r": 0.5,
        "n": 5
      },
      "expect": {
        "nth": 0.0625,
        "sum": 1.9375,
        "infinite": 2,
        "terms": "1, 0.5, 0.25, 0.125, 0.0625"
      },
      "source": "hand calculation in content.mdx: S₅ = (1 − 0.5⁵)/(1 − 0.5) = 1.9375, S∞ = 1/(1 − 0.5) = 2"
    },
    {
      "given": {
        "type": "arithmetic",
        "a": 0.1,
        "d": 0.2,
        "n": 3
      },
      "expect": {
        "nth": 0.5,
        "sum": 0.9,
        "terms": "0.1, 0.3, 0.5"
      },
      "source": "hand calculation in content.mdx: 0.1 + 0.3 + 0.5 = 0.9 in exact decimals"
    },
    {
      "given": {
        "type": "geometric",
        "a": 5,
        "r": -3,
        "n": 4
      },
      "expect": {
        "nth": -135,
        "sum": -100,
        "recursive": "a_1 = 5, a_n = (-3) × a_(n - 1)"
      },
      "source": "hand calculation in content.mdx: 5, −15, 45, −135; S₄ = 5(1 − 81)/(1 + 3) = −100"
    },
    {
      "given": {
        "type": "arithmetic",
        "a": 10,
        "d": -4,
        "n": 6
      },
      "expect": {
        "nth": -10,
        "sum": 0,
        "explicit": "a_n = 10 - 4(n - 1)"
      },
      "source": "hand calculation in content.mdx: 10, 6, 2, −2, −6, −10 add up to 0"
    }
  ],
  "sources": [
    "OpenStax, College Algebra 2e, section 9.2 Arithmetic Sequences: https://openstax.org/books/college-algebra-2e/pages/9-2-arithmetic-sequences",
    "OpenStax, College Algebra 2e, section 9.3 Geometric Sequences and 9.4 Series and Their Notations: https://openstax.org/books/college-algebra-2e/pages/9-4-series-and-their-notations"
  ],
  "related": [
    "summation",
    "exponential-growth",
    "exponent"
  ],
  "changelog": []
}
