swagger: '2.0'
info:
  title: 'Numbers API'
  version: '2.0'
  description: 'REST access to every number tool on Math Tools — number theory checks, numeral system conversions, cardinal/ordinal/currency spelling, base conversion, digits of pi, and more.'
host: math.tools
basePath: /api/numbers
schemes:
  - https
consumes:
  - application/json
produces:
  - application/json
securityDefinitions:
  BearerAuth:
    type: apiKey
    name: Authorization
    in: header
    description: 'A Sanctum personal access token (subscribe to a plan on this page to get one), sent as "Bearer <token>". There is no free/anonymous tier — every endpoint requires this.'
security:
  -
    BearerAuth: {}
paths:
  /fact:
    get:
      tags:
        - Numbers
      summary: 'A trivia fact about a number, if one is known — otherwise a fact derived from its number-theory properties (triangle, cube, square, and several classes of prime).'
      parameters:
        -
          name: number
          in: query
          required: true
          type: string
          description: 'The number to look up.'
      responses:
        200:
          description: '200 response'
          examples:
            application/json: |-
              {
                "success": { "total": 1 },
                "copyright": { "copyright": "2019-26 https://math.tools" },
                "contents": {
                  "number": 11,
                  "fact": "11 is the fifth prime and first palindromic multi-digit number"
                }
              }
        400:
          description: '400 response — a missing/invalid parameter, or a business-rule violation'
          examples:
            application/json: |-
              {
                  "error": {
                      "code": 400,
                      "message": "from value is greater than to value"
                  }
              }
        401:
          description: '401 response'
          examples:
            application/json: |-
              {
                  "error": {
                      "code": 401,
                      "message": "Unauthorized"
                  }
              }
  /random:
    get:
      tags:
        - Numbers
      summary: 'One or more random integers in a range.'
      parameters:
        -
          name: min
          in: query
          required: false
          type: string
          description: 'Lower bound. Default 1.'
        -
          name: max
          in: query
          required: false
          type: string
          description: "Upper bound. Default is PHP's own getrandmax()."
        -
          name: total
          in: query
          required: false
          type: string
          description: 'How many numbers to return, up to 100 (a higher value is silently capped, not rejected). Default 1.'
      responses:
        200:
          description: '200 response'
          examples:
            application/json: |-
              {
                "success": { "total": 1 },
                "copyright": { "copyright": "2019-26 https://math.tools" },
                "contents": {
                  "numbers": [9, 4, 8, 4, 3],
                  "min": 1,
                  "max": 10,
                  "requested": 5,
                  "returned": 5
                }
              }
        400:
          description: '400 response — a missing/invalid parameter, or a business-rule violation'
          examples:
            application/json: |-
              {
                  "error": {
                      "code": 400,
                      "message": "from value is greater than to value"
                  }
              }
        401:
          description: '401 response'
          examples:
            application/json: |-
              {
                  "error": {
                      "code": 401,
                      "message": "Unauthorized"
                  }
              }
  /nod:
    get:
      tags:
        - Numbers
      summary: "Today's number of the day and its full set of properties, facts, and number systems — the same daily pick shown on the /numbers/number-of-the-day/ page."
      parameters:
        -
          name: category
          in: query
          required: false
          type: string
          description: 'Number-of-the-day category shortname. Default "nod".'
      responses:
        200:
          description: '200 response'
          examples:
            application/json: |-
              {
                "success": { "total": 1 },
                "copyright": { "copyright": "2019-26 https://math.tools" },
                "contents": {
                  "nod": {
                    "category": {
                      "name": "Number of the day",
                      "description": "Number of the day and its properties, facts and anything else you may want to know about.",
                      "background": ""
                    },
                    "numbers": {
                      "number": "27982",
                      "uuid": "27982",
                      "id": "27982",
                      "names": { "nominal": { "name": "nominal", "description": "Nominal", "value": 27982, "display": "27982" }, "...": "..." },
                      "bases": { "binary": { "name": "binary", "description": "Base 2 (Binary)", "value": "110110101001110", "display": "110110101001110" }, "...": "..." },
                      "numerals": { "roman": { "name": "roman", "description": "27982 in Roman numerals", "value": "...", "display": "..." }, "...": "..." },
                      "general-facts": { "odd": { "name": "odd", "description": "Is 27982 an odd number?", "value": false, "display": "27982 is not an odd number" }, "...": "..." },
                      "prime-facts": { "prime": { "name": "prime", "description": "Is 27982 a prime number?", "value": false, "display": "27982 is not a prime number" }, "...": "..." },
                      "recreational": { "reverse": { "name": "reverse", "description": "Number 27982 reversed", "value": "28972", "display": "28972" }, "...": "..." },
                      "category": "nod"
                    }
                  }
                }
              }
        400:
          description: '400 response — a missing/invalid parameter, or a business-rule violation'
          examples:
            application/json: |-
              {
                  "error": {
                      "code": 400,
                      "message": "from value is greater than to value"
                  }
              }
        401:
          description: '401 response'
          examples:
            application/json: |-
              {
                  "error": {
                      "code": 401,
                      "message": "Unauthorized"
                  }
              }
  /cardinal:
    get:
      tags:
        - 'Spelling out a number'
      summary: 'Spells a number out in words. Also available at /api/numbers/words (identical response).'
      parameters:
        -
          name: number
          in: query
          required: true
          type: string
          description: 'The number to spell.'
        -
          name: lang
          in: query
          required: false
          type: string
          description: 'A locale code (e.g. en_US, fr_FR, de_DE). Default en_US.'
      responses:
        200:
          description: '200 response'
          examples:
            application/json: |-
              {
                "success": { "total": 1 },
                "copyright": { "copyright": "2019-26 https://math.tools" },
                "contents": {
                  "number": 2342,
                  "language": "en_US",
                  "result": "two thousand three hundred forty-two",
                  "cardinal": "two thousand three hundred forty-two"
                }
              }
        400:
          description: '400 response — a missing/invalid parameter, or a business-rule violation'
          examples:
            application/json: |-
              {
                  "error": {
                      "code": 400,
                      "message": "from value is greater than to value"
                  }
              }
        401:
          description: '401 response'
          examples:
            application/json: |-
              {
                  "error": {
                      "code": 401,
                      "message": "Unauthorized"
                  }
              }
  /ordinal:
    get:
      tags:
        - 'Spelling out a number'
      summary: 'The English ordinal form of a number (1st, 2nd, 3rd, ...), with the same thousands-separator formatting as every other spelled-out number on this page. English only — there is no lang parameter.'
      parameters:
        -
          name: number
          in: query
          required: true
          type: string
          description: 'The number to convert.'
      responses:
        200:
          description: '200 response'
          examples:
            application/json: |-
              {
                "success": { "total": 1 },
                "copyright": { "copyright": "2019-26 https://math.tools" },
                "contents": {
                  "number": 2342,
                  "result": "2,342nd",
                  "ordinal": "2,342nd"
                }
              }
        400:
          description: '400 response — a missing/invalid parameter, or a business-rule violation'
          examples:
            application/json: |-
              {
                  "error": {
                      "code": 400,
                      "message": "from value is greater than to value"
                  }
              }
        401:
          description: '401 response'
          examples:
            application/json: |-
              {
                  "error": {
                      "code": 401,
                      "message": "Unauthorized"
                  }
              }
  /currency:
    get:
      tags:
        - 'Spelling out a number'
      summary: 'Spells a number out as a currency amount.'
      parameters:
        -
          name: number
          in: query
          required: true
          type: string
          description: 'The number to spell.'
        -
          name: lang
          in: query
          required: false
          type: string
          description: 'A locale code. Default en_US.'
      responses:
        200:
          description: '200 response'
          examples:
            application/json: |-
              {
                "success": { "total": 1 },
                "copyright": { "copyright": "2019-26 https://math.tools" },
                "contents": {
                  "number": 1345456654,
                  "language": "en_US",
                  "result": "one billion three hundred forty-five million four hundred fifty-six thousand six hundred fifty-four dollars",
                  "currency": "one billion three hundred forty-five million four hundred fifty-six thousand six hundred fifty-four dollars"
                }
              }
        400:
          description: '400 response — a missing/invalid parameter, or a business-rule violation'
          examples:
            application/json: |-
              {
                  "error": {
                      "code": 400,
                      "message": "from value is greater than to value"
                  }
              }
        401:
          description: '401 response'
          examples:
            application/json: |-
              {
                  "error": {
                      "code": 401,
                      "message": "Unauthorized"
                  }
              }
  /numeral/roman:
    get:
      tags:
        - 'Converting to another numeral system'
      summary: 'Converts a base-10 number to a Roman numeral.'
      parameters:
        -
          name: number
          in: query
          required: true
          type: string
          description: 'The number to convert.'
      responses:
        200:
          description: '200 response'
          examples:
            application/json: |-
              {
                "success": { "total": 1 },
                "copyright": { "copyright": "2019-26 https://math.tools" },
                "contents": {
                  "number": 4568367,
                  "system": "roman",
                  "result": "<span class='u'>D</span><span class='u'>L</span><span class='u'>X</span><span class='u'>V</span>MMMCCCLXVII"
                }
              }
        400:
          description: '400 response — a missing/invalid parameter, or a business-rule violation'
          examples:
            application/json: |-
              {
                  "error": {
                      "code": 400,
                      "message": "from value is greater than to value"
                  }
              }
        401:
          description: '401 response'
          examples:
            application/json: |-
              {
                  "error": {
                      "code": 401,
                      "message": "Unauthorized"
                  }
              }
  /numeral/chinese:
    get:
      tags:
        - 'Converting to another numeral system'
      summary: 'Converts a base-10 number to a Chinese numeral.'
      parameters:
        -
          name: number
          in: query
          required: true
          type: string
          description: 'The number to convert.'
      responses:
        200:
          description: '200 response'
          examples:
            application/json: |-
              {
                "success": { "total": 1 },
                "copyright": { "copyright": "2019-26 https://math.tools" },
                "contents": {
                  "number": 4568367,
                  "system": "chinese",
                  "result": "伍拾萬陸萬捌仟叄佰陸拾柒"
                }
              }
        400:
          description: '400 response — a missing/invalid parameter, or a business-rule violation'
          examples:
            application/json: |-
              {
                  "error": {
                      "code": 400,
                      "message": "from value is greater than to value"
                  }
              }
        401:
          description: '401 response'
          examples:
            application/json: |-
              {
                  "error": {
                      "code": 401,
                      "message": "Unauthorized"
                  }
              }
  /numeral/egyptian:
    get:
      tags:
        - 'Converting to another numeral system'
      summary: 'Converts a base-10 number to an Egyptian numeral.'
      parameters:
        -
          name: number
          in: query
          required: true
          type: string
          description: 'The number to convert.'
      responses:
        200:
          description: '200 response'
          examples:
            application/json: |-
              {
                "success": { "total": 1 },
                "copyright": { "copyright": "2019-26 https://math.tools" },
                "contents": {
                  "number": 4568367,
                  "system": "egyptian",
                  "result": "&#x13068;&#x13068;&#x13068;&#x13068;&#x13190;&#x13190;&#x13190;&#x13190;&#x13190;&#x130b2;&#x131c3;&#x13364;&#x1338b;&#x13400;"
                }
              }
        400:
          description: '400 response — a missing/invalid parameter, or a business-rule violation'
          examples:
            application/json: |-
              {
                  "error": {
                      "code": 400,
                      "message": "from value is greater than to value"
                  }
              }
        401:
          description: '401 response'
          examples:
            application/json: |-
              {
                  "error": {
                      "code": 401,
                      "message": "Unauthorized"
                  }
              }
  /numeral/babylonian:
    get:
      tags:
        - 'Converting to another numeral system'
      summary: 'Converts a base-10 number to a Babylonian (sexagesimal) numeral — returned as plain comma-separated base-60 digits (e.g. "1,1,1"), not a cuneiform-glyph rendering.'
      parameters:
        -
          name: number
          in: query
          required: true
          type: string
          description: 'The number to convert.'
      responses:
        200:
          description: '200 response'
          examples:
            application/json: |-
              {
                "success": { "total": 1 },
                "copyright": { "copyright": "2019-26 https://math.tools" },
                "contents": {
                  "number": 3661,
                  "system": "babylonian",
                  "result": "1,1,1"
                }
              }
        400:
          description: '400 response — a missing/invalid parameter, or a business-rule violation'
          examples:
            application/json: |-
              {
                  "error": {
                      "code": 400,
                      "message": "from value is greater than to value"
                  }
              }
        401:
          description: '401 response'
          examples:
            application/json: |-
              {
                  "error": {
                      "code": 401,
                      "message": "Unauthorized"
                  }
              }
  /numeral/mayan:
    get:
      tags:
        - 'Converting to another numeral system'
      summary: 'Converts a base-10 number to a Mayan (vigesimal) numeral, using the real Unicode Mayan Numerals block (U+1D2E0-U+1D2F3).'
      parameters:
        -
          name: number
          in: query
          required: true
          type: string
          description: 'The number to convert.'
      responses:
        200:
          description: '200 response'
        400:
          description: '400 response — a missing/invalid parameter, or a business-rule violation'
          examples:
            application/json: |-
              {
                  "error": {
                      "code": 400,
                      "message": "from value is greater than to value"
                  }
              }
        401:
          description: '401 response'
          examples:
            application/json: |-
              {
                  "error": {
                      "code": 401,
                      "message": "Unauthorized"
                  }
              }
  /gcf:
    get:
      tags:
        - 'Greatest common factor / least common multiple'
      summary: 'The greatest common factor (GCF/GCD) of two or more numbers.'
      parameters:
        -
          name: numbers
          in: query
          required: true
          type: string
          description: 'A comma-separated list of integers, e.g. "12,18,24" (up to 10).'
      responses:
        200:
          description: '200 response'
          examples:
            application/json: |-
              {
                "success": { "total": 1 },
                "copyright": { "copyright": "2019-26 https://math.tools" },
                "contents": {
                  "numbers": [12, 18, 24],
                  "answer": 6
                }
              }
        400:
          description: '400 response — a missing/invalid parameter, or a business-rule violation'
          examples:
            application/json: |-
              {
                  "error": {
                      "code": 400,
                      "message": "from value is greater than to value"
                  }
              }
        401:
          description: '401 response'
          examples:
            application/json: |-
              {
                  "error": {
                      "code": 401,
                      "message": "Unauthorized"
                  }
              }
  /lcm:
    get:
      tags:
        - 'Greatest common factor / least common multiple'
      summary: 'The least common multiple (LCM) of two or more numbers.'
      parameters:
        -
          name: numbers
          in: query
          required: true
          type: string
          description: 'A comma-separated list of integers, e.g. "4,6" (up to 10).'
      responses:
        200:
          description: '200 response'
          examples:
            application/json: |-
              {
                "success": { "total": 1 },
                "copyright": { "copyright": "2019-26 https://math.tools" },
                "contents": {
                  "numbers": [4, 6],
                  "answer": 12
                }
              }
        400:
          description: '400 response — a missing/invalid parameter, or a business-rule violation'
          examples:
            application/json: |-
              {
                  "error": {
                      "code": 400,
                      "message": "from value is greater than to value"
                  }
              }
        401:
          description: '401 response'
          examples:
            application/json: |-
              {
                  "error": {
                      "code": 401,
                      "message": "Unauthorized"
                  }
              }
  /list/primes:
    get:
      tags:
        - Lists
      summary: 'The first N prime numbers.'
      parameters:
        -
          name: count
          in: query
          required: false
          type: string
          description: 'How many to return, clamped to a configured maximum rather than rejected.'
      responses:
        200:
          description: '200 response'
          examples:
            application/json: |-
              {
                "success": { "total": 1 },
                "copyright": { "copyright": "2019-26 https://math.tools" },
                "contents": {
                  "count": 5,
                  "numbers": [2, 3, 5, 7, 11]
                }
              }
        400:
          description: '400 response — a missing/invalid parameter, or a business-rule violation'
          examples:
            application/json: |-
              {
                  "error": {
                      "code": 400,
                      "message": "from value is greater than to value"
                  }
              }
        401:
          description: '401 response'
          examples:
            application/json: |-
              {
                  "error": {
                      "code": 401,
                      "message": "Unauthorized"
                  }
              }
  /list/composites:
    get:
      tags:
        - Lists
      summary: 'The first N composite numbers.'
      parameters:
        -
          name: count
          in: query
          required: false
          type: string
          description: 'How many to return, clamped to a configured maximum rather than rejected.'
      responses:
        200:
          description: '200 response'
        400:
          description: '400 response — a missing/invalid parameter, or a business-rule violation'
          examples:
            application/json: |-
              {
                  "error": {
                      "code": 400,
                      "message": "from value is greater than to value"
                  }
              }
        401:
          description: '401 response'
          examples:
            application/json: |-
              {
                  "error": {
                      "code": 401,
                      "message": "Unauthorized"
                  }
              }
  /list/palindromes:
    get:
      tags:
        - Lists
      summary: 'The first N palindromic numbers.'
      parameters:
        -
          name: count
          in: query
          required: false
          type: string
          description: 'How many to return, clamped to a configured maximum rather than rejected.'
      responses:
        200:
          description: '200 response'
        400:
          description: '400 response — a missing/invalid parameter, or a business-rule violation'
          examples:
            application/json: |-
              {
                  "error": {
                      "code": 400,
                      "message": "from value is greater than to value"
                  }
              }
        401:
          description: '401 response'
          examples:
            application/json: |-
              {
                  "error": {
                      "code": 401,
                      "message": "Unauthorized"
                  }
              }
  /pi:
    get:
      tags:
        - 'Digits of Pi (π)'
      summary: 'A slice of the digits of pi.'
      parameters:
        -
          name: from
          in: query
          required: false
          type: string
          description: 'Start offset into the digit string. Default 0.'
        -
          name: to
          in: query
          required: false
          type: string
          description: 'Length of the slice returned, counted from "from" (not an end position — from=50&to=100 returns 100 digits starting at offset 50, not the digits between 50 and 100). Default 100.'
      responses:
        200:
          description: '200 response'
          examples:
            application/json: |-
              {
                "success": { "total": 1 },
                "copyright": { "copyright": "2019-26 https://math.tools" },
                "contents": {
                  "from": 0,
                  "to": 100,
                  "result": "3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679",
                  "number": "pi"
                }
              }
        400:
          description: '400 response — a missing/invalid parameter, or a business-rule violation'
          examples:
            application/json: |-
              {
                  "error": {
                      "code": 400,
                      "message": "from value is greater than to value"
                  }
              }
        401:
          description: '401 response'
          examples:
            application/json: |-
              {
                  "error": {
                      "code": 401,
                      "message": "Unauthorized"
                  }
              }
  /base:
    get:
      tags:
        - 'Converting to another base'
      summary: 'Converts a number from any base to any other base (2-64).'
      parameters:
        -
          name: number
          in: query
          required: true
          type: string
          description: 'The number to convert, written in base "from".'
        -
          name: to
          in: query
          required: true
          type: string
          description: 'The target base.'
        -
          name: from
          in: query
          required: false
          type: string
          description: 'The source base. Default 10.'
      responses:
        200:
          description: '200 response'
          examples:
            application/json: |-
              {
                "success": { "total": 1 },
                "copyright": { "copyright": "2019-26 https://math.tools" },
                "contents": {
                  "number": 88,
                  "base": { "from": 10, "to": 12 },
                  "answer": "74"
                }
              }
        400:
          description: '400 response — a missing/invalid parameter, or a business-rule violation'
          examples:
            application/json: |-
              {
                  "error": {
                      "code": 400,
                      "message": "from value is greater than to value"
                  }
              }
        401:
          description: '401 response'
          examples:
            application/json: |-
              {
                  "error": {
                      "code": 401,
                      "message": "Unauthorized"
                  }
              }
  /base/binary:
    get:
      tags:
        - 'Converting to another base'
      summary: 'Converts a number to binary (base 2). Shorthand for /api/numbers/base?to=2.'
      parameters:
        -
          name: number
          in: query
          required: true
          type: string
          description: 'The number to convert.'
        -
          name: from
          in: query
          required: false
          type: string
          description: 'The source base. Default 10.'
      responses:
        200:
          description: '200 response'
          examples:
            application/json: |-
              {
                "success": { "total": 1 },
                "copyright": { "copyright": "2019-26 https://math.tools" },
                "contents": {
                  "number": 32,
                  "base": { "from": 10, "to": 2 },
                  "answer": "100000"
                }
              }
        400:
          description: '400 response — a missing/invalid parameter, or a business-rule violation'
          examples:
            application/json: |-
              {
                  "error": {
                      "code": 400,
                      "message": "from value is greater than to value"
                  }
              }
        401:
          description: '401 response'
          examples:
            application/json: |-
              {
                  "error": {
                      "code": 401,
                      "message": "Unauthorized"
                  }
              }
  /base/octal:
    get:
      tags:
        - 'Converting to another base'
      summary: 'Converts a number to octal (base 8). Shorthand for /api/numbers/base?to=8.'
      parameters:
        -
          name: number
          in: query
          required: true
          type: string
          description: 'The number to convert.'
        -
          name: from
          in: query
          required: false
          type: string
          description: 'The source base. Default 10.'
      responses:
        200:
          description: '200 response'
        400:
          description: '400 response — a missing/invalid parameter, or a business-rule violation'
          examples:
            application/json: |-
              {
                  "error": {
                      "code": 400,
                      "message": "from value is greater than to value"
                  }
              }
        401:
          description: '401 response'
          examples:
            application/json: |-
              {
                  "error": {
                      "code": 401,
                      "message": "Unauthorized"
                  }
              }
  /base/hex:
    get:
      tags:
        - 'Converting to another base'
      summary: 'Converts a number to hexadecimal (base 16). Shorthand for /api/numbers/base?to=16.'
      parameters:
        -
          name: number
          in: query
          required: true
          type: string
          description: 'The number to convert.'
        -
          name: from
          in: query
          required: false
          type: string
          description: 'The source base. Default 10.'
      responses:
        200:
          description: '200 response'
        400:
          description: '400 response — a missing/invalid parameter, or a business-rule violation'
          examples:
            application/json: |-
              {
                  "error": {
                      "code": 400,
                      "message": "from value is greater than to value"
                  }
              }
        401:
          description: '401 response'
          examples:
            application/json: |-
              {
                  "error": {
                      "code": 401,
                      "message": "Unauthorized"
                  }
              }
  /prime/is-prime:
    get:
      tags:
        - 'Number theory checks'
      summary: 'Is this number prime?'
      parameters:
        -
          name: number
          in: query
          required: true
          type: string
          description: 'The number to check.'
      responses:
        200:
          description: '200 response'
          examples:
            application/json: |-
              {
                "success": { "total": 1 },
                "copyright": { "copyright": "2019-26 https://math.tools" },
                "contents": { "number": 17, "answer": true }
              }
        400:
          description: '400 response — a missing/invalid parameter, or a business-rule violation'
          examples:
            application/json: |-
              {
                  "error": {
                      "code": 400,
                      "message": "from value is greater than to value"
                  }
              }
        401:
          description: '401 response'
          examples:
            application/json: |-
              {
                  "error": {
                      "code": 401,
                      "message": "Unauthorized"
                  }
              }
  /is-composite:
    get:
      tags:
        - 'Number theory checks'
      summary: 'Is this a composite number (a positive integer with a factor other than 1 and itself)?'
      parameters:
        -
          name: number
          in: query
          required: true
          type: string
          description: 'The number to check.'
      responses:
        200:
          description: '200 response'
        400:
          description: '400 response — a missing/invalid parameter, or a business-rule violation'
          examples:
            application/json: |-
              {
                  "error": {
                      "code": 400,
                      "message": "from value is greater than to value"
                  }
              }
        401:
          description: '401 response'
          examples:
            application/json: |-
              {
                  "error": {
                      "code": 401,
                      "message": "Unauthorized"
                  }
              }
  /is-odd:
    get:
      tags:
        - 'Number theory checks'
      summary: 'Is this number odd?'
      parameters:
        -
          name: number
          in: query
          required: true
          type: string
          description: 'The number to check.'
      responses:
        200:
          description: '200 response'
        400:
          description: '400 response — a missing/invalid parameter, or a business-rule violation'
          examples:
            application/json: |-
              {
                  "error": {
                      "code": 400,
                      "message": "from value is greater than to value"
                  }
              }
        401:
          description: '401 response'
          examples:
            application/json: |-
              {
                  "error": {
                      "code": 401,
                      "message": "Unauthorized"
                  }
              }
  /is-even:
    get:
      tags:
        - 'Number theory checks'
      summary: 'Is this number even?'
      parameters:
        -
          name: number
          in: query
          required: true
          type: string
          description: 'The number to check.'
      responses:
        200:
          description: '200 response'
        400:
          description: '400 response — a missing/invalid parameter, or a business-rule violation'
          examples:
            application/json: |-
              {
                  "error": {
                      "code": 400,
                      "message": "from value is greater than to value"
                  }
              }
        401:
          description: '401 response'
          examples:
            application/json: |-
              {
                  "error": {
                      "code": 401,
                      "message": "Unauthorized"
                  }
              }
  /prime/factors:
    get:
      tags:
        - 'Number theory checks'
      summary: 'The prime factorization of a number, as a list of {factor, times} pairs.'
      parameters:
        -
          name: number
          in: query
          required: true
          type: string
          description: 'The number to factorize.'
      responses:
        200:
          description: '200 response'
          examples:
            application/json: |-
              {
                "success": { "total": 1 },
                "copyright": { "copyright": "2019-26 https://math.tools" },
                "contents": {
                  "number": 60,
                  "answer": [
                    { "factor": 2, "times": 2 },
                    { "factor": 3, "times": 1 },
                    { "factor": 5, "times": 1 }
                  ],
                  "prime-factors": [
                    { "factor": 2, "times": 2 },
                    { "factor": 3, "times": 1 },
                    { "factor": 5, "times": 1 }
                  ]
                }
              }
        400:
          description: '400 response — a missing/invalid parameter, or a business-rule violation'
          examples:
            application/json: |-
              {
                  "error": {
                      "code": 400,
                      "message": "from value is greater than to value"
                  }
              }
        401:
          description: '401 response'
          examples:
            application/json: |-
              {
                  "error": {
                      "code": 401,
                      "message": "Unauthorized"
                  }
              }
  /is-palindrome:
    get:
      tags:
        - 'Number theory checks'
      summary: 'Is this number a palindrome (reads the same forwards and backwards)?'
      parameters:
        -
          name: number
          in: query
          required: true
          type: string
          description: 'The number to check.'
      responses:
        200:
          description: '200 response'
          examples:
            application/json: |-
              {
                "success": { "total": 1 },
                "copyright": { "copyright": "2019-26 https://math.tools" },
                "contents": { "number": 456654, "answer": true }
              }
        400:
          description: '400 response — a missing/invalid parameter, or a business-rule violation'
          examples:
            application/json: |-
              {
                  "error": {
                      "code": 400,
                      "message": "from value is greater than to value"
                  }
              }
        401:
          description: '401 response'
          examples:
            application/json: |-
              {
                  "error": {
                      "code": 401,
                      "message": "Unauthorized"
                  }
              }
  /is-triangle:
    get:
      tags:
        - 'Number theory checks'
      summary: 'Is this a triangle number?'
      parameters:
        -
          name: number
          in: query
          required: true
          type: string
          description: 'The number to check.'
      responses:
        200:
          description: '200 response'
        400:
          description: '400 response — a missing/invalid parameter, or a business-rule violation'
          examples:
            application/json: |-
              {
                  "error": {
                      "code": 400,
                      "message": "from value is greater than to value"
                  }
              }
        401:
          description: '401 response'
          examples:
            application/json: |-
              {
                  "error": {
                      "code": 401,
                      "message": "Unauthorized"
                  }
              }
  /is-square:
    get:
      tags:
        - 'Number theory checks'
      summary: 'Is this a perfect square?'
      parameters:
        -
          name: number
          in: query
          required: true
          type: string
          description: 'The number to check.'
      responses:
        200:
          description: '200 response'
        400:
          description: '400 response — a missing/invalid parameter, or a business-rule violation'
          examples:
            application/json: |-
              {
                  "error": {
                      "code": 400,
                      "message": "from value is greater than to value"
                  }
              }
        401:
          description: '401 response'
          examples:
            application/json: |-
              {
                  "error": {
                      "code": 401,
                      "message": "Unauthorized"
                  }
              }
  /is-cube:
    get:
      tags:
        - 'Number theory checks'
      summary: 'Is this a perfect cube?'
      parameters:
        -
          name: number
          in: query
          required: true
          type: string
          description: 'The number to check.'
      responses:
        200:
          description: '200 response'
        400:
          description: '400 response — a missing/invalid parameter, or a business-rule violation'
          examples:
            application/json: |-
              {
                  "error": {
                      "code": 400,
                      "message": "from value is greater than to value"
                  }
              }
        401:
          description: '401 response'
          examples:
            application/json: |-
              {
                  "error": {
                      "code": 401,
                      "message": "Unauthorized"
                  }
              }
  /is-perfect:
    get:
      tags:
        - 'Number theory checks'
      summary: 'Is this a perfect number (equal to the sum of its proper divisors)?'
      parameters:
        -
          name: number
          in: query
          required: true
          type: string
          description: 'The number to check.'
      responses:
        200:
          description: '200 response'
        400:
          description: '400 response — a missing/invalid parameter, or a business-rule violation'
          examples:
            application/json: |-
              {
                  "error": {
                      "code": 400,
                      "message": "from value is greater than to value"
                  }
              }
        401:
          description: '401 response'
          examples:
            application/json: |-
              {
                  "error": {
                      "code": 401,
                      "message": "Unauthorized"
                  }
              }
  /is-mersenne-prime:
    get:
      tags:
        - 'Number theory checks'
      summary: 'Is this a known Mersenne prime?'
      parameters:
        -
          name: number
          in: query
          required: true
          type: string
          description: 'The number to check.'
      responses:
        200:
          description: '200 response'
        400:
          description: '400 response — a missing/invalid parameter, or a business-rule violation'
          examples:
            application/json: |-
              {
                  "error": {
                      "code": 400,
                      "message": "from value is greater than to value"
                  }
              }
        401:
          description: '401 response'
          examples:
            application/json: |-
              {
                  "error": {
                      "code": 401,
                      "message": "Unauthorized"
                  }
              }
  /is-fermat-prime:
    get:
      tags:
        - 'Number theory checks'
      summary: 'Is this a known Fermat prime?'
      parameters:
        -
          name: number
          in: query
          required: true
          type: string
          description: 'The number to check.'
      responses:
        200:
          description: '200 response'
        400:
          description: '400 response — a missing/invalid parameter, or a business-rule violation'
          examples:
            application/json: |-
              {
                  "error": {
                      "code": 400,
                      "message": "from value is greater than to value"
                  }
              }
        401:
          description: '401 response'
          examples:
            application/json: |-
              {
                  "error": {
                      "code": 401,
                      "message": "Unauthorized"
                  }
              }
  /is-fibonacci-prime:
    get:
      tags:
        - 'Number theory checks'
      summary: 'Is this a known Fibonacci prime?'
      parameters:
        -
          name: number
          in: query
          required: true
          type: string
          description: 'The number to check.'
      responses:
        200:
          description: '200 response'
        400:
          description: '400 response — a missing/invalid parameter, or a business-rule violation'
          examples:
            application/json: |-
              {
                  "error": {
                      "code": 400,
                      "message": "from value is greater than to value"
                  }
              }
        401:
          description: '401 response'
          examples:
            application/json: |-
              {
                  "error": {
                      "code": 401,
                      "message": "Unauthorized"
                  }
              }
  /is-pell-prime:
    get:
      tags:
        - 'Number theory checks'
      summary: 'Is this a known Pell prime?'
      parameters:
        -
          name: number
          in: query
          required: true
          type: string
          description: 'The number to check.'
      responses:
        200:
          description: '200 response'
        400:
          description: '400 response — a missing/invalid parameter, or a business-rule violation'
          examples:
            application/json: |-
              {
                  "error": {
                      "code": 400,
                      "message": "from value is greater than to value"
                  }
              }
        401:
          description: '401 response'
          examples:
            application/json: |-
              {
                  "error": {
                      "code": 401,
                      "message": "Unauthorized"
                  }
              }
  /is-partition-prime:
    get:
      tags:
        - 'Number theory checks'
      summary: 'Is this a known partition prime?'
      parameters:
        -
          name: number
          in: query
          required: true
          type: string
          description: 'The number to check.'
      responses:
        200:
          description: '200 response'
        400:
          description: '400 response — a missing/invalid parameter, or a business-rule violation'
          examples:
            application/json: |-
              {
                  "error": {
                      "code": 400,
                      "message": "from value is greater than to value"
                  }
              }
        401:
          description: '401 response'
          examples:
            application/json: |-
              {
                  "error": {
                      "code": 401,
                      "message": "Unauthorized"
                  }
              }
  /is-abundant:
    get:
      tags:
        - 'Number Properties'
      summary: 'Is this an abundant number (its proper divisors sum to more than the number itself)?'
      parameters:
        -
          name: number
          in: query
          required: true
          type: string
          description: 'The number to check.'
      responses:
        200:
          description: '200 response'
          examples:
            application/json: |-
              {
                "success": { "total": 1 },
                "copyright": { "copyright": "2019-26 https://math.tools" },
                "contents": { "number": 12, "answer": true }
              }
        400:
          description: '400 response — a missing/invalid parameter, or a business-rule violation'
          examples:
            application/json: |-
              {
                  "error": {
                      "code": 400,
                      "message": "from value is greater than to value"
                  }
              }
        401:
          description: '401 response'
          examples:
            application/json: |-
              {
                  "error": {
                      "code": 401,
                      "message": "Unauthorized"
                  }
              }
  /is-deficient:
    get:
      tags:
        - 'Number Properties'
      summary: 'Is this a deficient number (its proper divisors sum to less than the number itself)?'
      parameters:
        -
          name: number
          in: query
          required: true
          type: string
          description: 'The number to check.'
      responses:
        200:
          description: '200 response'
        400:
          description: '400 response — a missing/invalid parameter, or a business-rule violation'
          examples:
            application/json: |-
              {
                  "error": {
                      "code": 400,
                      "message": "from value is greater than to value"
                  }
              }
        401:
          description: '401 response'
          examples:
            application/json: |-
              {
                  "error": {
                      "code": 401,
                      "message": "Unauthorized"
                  }
              }
  /is-squarefree:
    get:
      tags:
        - 'Number Properties'
      summary: 'Is this number squarefree (not divisible by any perfect square other than 1 — equivalently, no repeated prime factors)?'
      parameters:
        -
          name: number
          in: query
          required: true
          type: string
          description: 'The number to check.'
      responses:
        200:
          description: '200 response'
        400:
          description: '400 response — a missing/invalid parameter, or a business-rule violation'
          examples:
            application/json: |-
              {
                  "error": {
                      "code": 400,
                      "message": "from value is greater than to value"
                  }
              }
        401:
          description: '401 response'
          examples:
            application/json: |-
              {
                  "error": {
                      "code": 401,
                      "message": "Unauthorized"
                  }
              }
  /totient:
    get:
      tags:
        - 'Number Properties'
      summary: "Euler's totient function φ(n): how many integers from 1 to n are coprime with n. Requires n ≥ 1."
      parameters:
        -
          name: number
          in: query
          required: true
          type: string
          description: 'The number to compute φ(n) for.'
      responses:
        200:
          description: '200 response'
          examples:
            application/json: |-
              {
                "success": { "total": 1 },
                "copyright": { "copyright": "2019-26 https://math.tools" },
                "contents": { "number": 36, "answer": 12 }
              }
        400:
          description: '400 response — a missing/invalid parameter, or a business-rule violation'
          examples:
            application/json: |-
              {
                  "error": {
                      "code": 400,
                      "message": "from value is greater than to value"
                  }
              }
        401:
          description: '401 response'
          examples:
            application/json: |-
              {
                  "error": {
                      "code": 401,
                      "message": "Unauthorized"
                  }
              }
  /number-of-divisors:
    get:
      tags:
        - 'Number Properties'
      summary: 'How many positive divisors n has, including 1 and n itself. Requires n ≥ 1.'
      parameters:
        -
          name: number
          in: query
          required: true
          type: string
          description: 'The number to check.'
      responses:
        200:
          description: '200 response'
        400:
          description: '400 response — a missing/invalid parameter, or a business-rule violation'
          examples:
            application/json: |-
              {
                  "error": {
                      "code": 400,
                      "message": "from value is greater than to value"
                  }
              }
        401:
          description: '401 response'
          examples:
            application/json: |-
              {
                  "error": {
                      "code": 401,
                      "message": "Unauthorized"
                  }
              }
  /sum-of-divisors:
    get:
      tags:
        - 'Number Properties'
      summary: 'The sum of all positive divisors of n, including n itself. Requires n ≥ 1.'
      parameters:
        -
          name: number
          in: query
          required: true
          type: string
          description: 'The number to check.'
      responses:
        200:
          description: '200 response'
        400:
          description: '400 response — a missing/invalid parameter, or a business-rule violation'
          examples:
            application/json: |-
              {
                  "error": {
                      "code": 400,
                      "message": "from value is greater than to value"
                  }
              }
        401:
          description: '401 response'
          examples:
            application/json: |-
              {
                  "error": {
                      "code": 401,
                      "message": "Unauthorized"
                  }
              }
  /aliquot-sum:
    get:
      tags:
        - 'Number Properties'
      summary: "The sum of n's proper divisors (every divisor except n itself) — equal to n for a perfect number, greater for an abundant number, less for a deficient one. Requires n ≥ 1."
      parameters:
        -
          name: number
          in: query
          required: true
          type: string
          description: 'The number to check.'
      responses:
        200:
          description: '200 response'
        400:
          description: '400 response — a missing/invalid parameter, or a business-rule violation'
          examples:
            application/json: |-
              {
                  "error": {
                      "code": 400,
                      "message": "from value is greater than to value"
                  }
              }
        401:
          description: '401 response'
          examples:
            application/json: |-
              {
                  "error": {
                      "code": 401,
                      "message": "Unauthorized"
                  }
              }
  /coprime:
    get:
      tags:
        - 'Number Properties'
      summary: 'Are a and b coprime (their only common positive divisor is 1)? The only endpoint on this page that takes two numbers instead of one.'
      parameters:
        -
          name: a
          in: query
          required: true
          type: string
          description: 'The first number.'
        -
          name: b
          in: query
          required: true
          type: string
          description: 'The second number.'
      responses:
        200:
          description: '200 response'
          examples:
            application/json: |-
              {
                "success": { "total": 1 },
                "copyright": { "copyright": "2019-26 https://math.tools" },
                "contents": { "a": 8, "b": 15, "answer": true }
              }
        400:
          description: '400 response — a missing/invalid parameter, or a business-rule violation'
          examples:
            application/json: |-
              {
                  "error": {
                      "code": 400,
                      "message": "from value is greater than to value"
                  }
              }
        401:
          description: '401 response'
          examples:
            application/json: |-
              {
                  "error": {
                      "code": 401,
                      "message": "Unauthorized"
                  }
              }