{
  "id": "perimeter",
  "version": "059874a6375b",
  "status": "published",
  "name": "Perimeter Calculator",
  "question": "What is the perimeter?",
  "summary": "Finds the perimeter of a square, rectangle, triangle, circle (its circumference), regular polygon, or any polygon from its side lengths, with the formula worked out.",
  "category": "math",
  "subcategory": "geometry",
  "url": "https://www.acalculator.org/math/perimeter-calculator",
  "markdown": "https://www.acalculator.org/math/perimeter-calculator.md",
  "kind": "function",
  "method": "Square P = 4a; rectangle or parallelogram P = 2L + 2W; triangle P = a + b + c; circle C = 2πr; regular polygon P = n × s; any polygon P = the sum of its sides.",
  "assumptions": [
    "Lengths are in any one unit; the perimeter is in the same unit.",
    "A triangle’s longest side must be shorter than the other two together; a polygon’s longest side shorter than all the others together.",
    "The circumference uses π to double precision, not 3.14."
  ],
  "inputs": {
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "type": "object",
    "properties": {
      "shape": {
        "title": "Shape",
        "description": "The shape whose perimeter you want.",
        "type": "string",
        "enum": [
          "square",
          "rectangle",
          "triangle",
          "circle",
          "regular",
          "polygon"
        ]
      },
      "a": {
        "title": "Side a",
        "description": "The length of one side.",
        "type": "number",
        "exclusiveMinimum": 0,
        "maximum": 1000000000000
      },
      "l": {
        "title": "Length",
        "description": "The length of the rectangle (or one side of the parallelogram).",
        "type": "number",
        "exclusiveMinimum": 0,
        "maximum": 1000000000000
      },
      "w": {
        "title": "Width",
        "description": "The width of the rectangle (or the other side of the parallelogram).",
        "type": "number",
        "exclusiveMinimum": 0,
        "maximum": 1000000000000
      },
      "b": {
        "title": "Side b",
        "description": "The length of the second side.",
        "type": "number",
        "exclusiveMinimum": 0,
        "maximum": 1000000000000
      },
      "c": {
        "title": "Side c",
        "description": "The length of the third side.",
        "type": "number",
        "exclusiveMinimum": 0,
        "maximum": 1000000000000
      },
      "r": {
        "title": "Radius",
        "description": "The distance from the centre to the edge: half the diameter.",
        "type": "number",
        "exclusiveMinimum": 0,
        "maximum": 1000000000000
      },
      "n": {
        "title": "Number of sides",
        "description": "How many equal sides the regular polygon has, from 3 to 1,000.",
        "type": "integer",
        "minimum": 3,
        "maximum": 1000
      },
      "s": {
        "title": "Side length",
        "description": "The length of each side of the regular polygon.",
        "type": "number",
        "exclusiveMinimum": 0,
        "maximum": 1000000000000
      },
      "sides": {
        "title": "Side lengths",
        "description": "The length of every side, in order, separated by commas: 3 to 100 sides.",
        "type": "array",
        "items": {
          "type": "number"
        }
      }
    }
  },
  "outputs": {
    "perimeter": {
      "label": "Perimeter",
      "description": "The total length around the shape, in the unit of the lengths you typed.",
      "format": "number"
    },
    "formula": {
      "label": "Working",
      "description": "The formula with your numbers.",
      "format": "text"
    },
    "diameter": {
      "label": "Diameter",
      "description": "For a circle: twice the radius.",
      "format": "number"
    }
  },
  "defaultAnswer": {
    "inputs": {
      "shape": "rectangle",
      "a": 5,
      "l": 32,
      "w": 20,
      "b": 9,
      "c": 11,
      "r": 2,
      "n": 6,
      "s": 4,
      "sides": [
        10,
        6,
        4,
        5
      ]
    },
    "outputs": {
      "perimeter": 104,
      "formula": "P = 2L + 2W = 2 × 32 + 2 × 20 = 104"
    },
    "text": "The perimeter is 104."
  },
  "examples": [
    {
      "given": {
        "shape": "rectangle",
        "l": 32,
        "w": 20
      },
      "expect": {
        "perimeter": 104,
        "formula": "P = 2L + 2W = 2 × 32 + 2 × 20 = 104"
      },
      "source": "OpenStax, Prealgebra 2e, §9.4 Use Properties of Rectangles, Triangles, and Trapezoids (P = 2L + 2W, P = a + b + c; Example 9.27: a 32 m by 20 m rectangle has P = 104 m), https://openstax.org/books/prealgebra-2e/pages/9-4-use-properties-of-rectangles-triangles-and-trapezoids (retrieved 2026-10-02)"
    },
    {
      "given": {
        "shape": "triangle",
        "a": 4,
        "b": 9,
        "c": 11
      },
      "expect": {
        "perimeter": 24
      },
      "source": "OpenStax, Prealgebra 2e, §9.4 Use Properties of Rectangles, Triangles, and Trapezoids (P = 2L + 2W, P = a + b + c; Example 9.27: a 32 m by 20 m rectangle has P = 104 m), https://openstax.org/books/prealgebra-2e/pages/9-4-use-properties-of-rectangles-triangles-and-trapezoids (retrieved 2026-10-02)"
    },
    {
      "given": {
        "shape": "circle",
        "r": 2
      },
      "expect": {
        "perimeter": 12.566370614359172,
        "diameter": 4
      },
      "source": "OpenStax, Prealgebra 2e, §9.5 Solve Geometry Applications: Circles and Irregular Figures (C = 2πr = πd; Example 9.42: a 4 ft diameter gives C ≈ 12.56 ft with π ≈ 3.14), https://openstax.org/books/prealgebra-2e/pages/9-5-solve-geometry-applications-circles-and-irregular-figures (retrieved 2026-10-02); the page uses π, not 3.14; Python 3: 2*math.pi*2"
    },
    {
      "given": {
        "shape": "square",
        "a": 31
      },
      "expect": {
        "perimeter": 124
      },
      "source": "hand calculation in content.mdx: 4 × 31 = 124; OpenStax, Prealgebra 2e, §9.4 Use Properties of Rectangles, Triangles, and Trapezoids (P = 2L + 2W, P = a + b + c; Example 9.27: a 32 m by 20 m rectangle has P = 104 m), https://openstax.org/books/prealgebra-2e/pages/9-4-use-properties-of-rectangles-triangles-and-trapezoids (retrieved 2026-10-02)"
    },
    {
      "given": {
        "shape": "regular",
        "n": 6,
        "s": 4
      },
      "expect": {
        "perimeter": 24,
        "formula": "P = n × s = 6 × 4 = 24"
      },
      "source": "hand calculation in content.mdx: a hexagon has 6 equal sides, 6 × 4 = 24; OpenStax, Prealgebra 2e, §9.4 Use Properties of Rectangles, Triangles, and Trapezoids (P = 2L + 2W, P = a + b + c; Example 9.27: a 32 m by 20 m rectangle has P = 104 m), https://openstax.org/books/prealgebra-2e/pages/9-4-use-properties-of-rectangles-triangles-and-trapezoids (retrieved 2026-10-02)"
    },
    {
      "given": {
        "shape": "polygon",
        "sides": [
          10,
          6,
          4,
          5
        ]
      },
      "expect": {
        "perimeter": 25,
        "formula": "P = 10 + 6 + 4 + 5 = 25"
      },
      "source": "hand calculation in content.mdx: the sides of a trapezoid added up; OpenStax, Prealgebra 2e, §9.4 Use Properties of Rectangles, Triangles, and Trapezoids (P = 2L + 2W, P = a + b + c; Example 9.27: a 32 m by 20 m rectangle has P = 104 m), https://openstax.org/books/prealgebra-2e/pages/9-4-use-properties-of-rectangles-triangles-and-trapezoids (retrieved 2026-10-02)"
    }
  ],
  "sources": [
    "OpenStax, Prealgebra 2e, §9.4 Use Properties of Rectangles, Triangles, and Trapezoids (P = 2L + 2W, P = a + b + c; Example 9.27: a 32 m by 20 m rectangle has P = 104 m; Example 9.34: sides 4 ft and 9 ft with P = 24 ft leave 11 ft). https://openstax.org/books/prealgebra-2e/pages/9-4-use-properties-of-rectangles-triangles-and-trapezoids (retrieved 2026-10-02)",
    "OpenStax, Prealgebra 2e, §9.5 Solve Geometry Applications: Circles and Irregular Figures (C = 2πr = πd; Example 9.42: a 4 ft diameter gives C ≈ 12.56 ft with π ≈ 3.14). https://openstax.org/books/prealgebra-2e/pages/9-5-solve-geometry-applications-circles-and-irregular-figures (retrieved 2026-10-02)"
  ],
  "related": [
    "area",
    "circle",
    "triangle",
    "square-footage"
  ],
  "changelog": []
}
