ForHosting KIT · Math

Kaprekar number checker

45 is a Kaprekar number: 45 squared is 2025, and 20 plus 25 gives 45 again. Enter any positive integer to test every way of splitting its square and see the left and right parts when a valid split exists. Free in your browser.

  • Free
  • Runs in your browser
  • No sign-up
  • Your data stays on your device
Use it from WebAPIEmailTelegramApp soon
If you enter
N
45
You get
Square
2025
Left
20
Right
25

The Kaprekar number checker answers a classic recreational number-theory question: for a positive integer n, can the decimal digits of n squared be split into a left part and a right part that add back to n itself? Famous examples include forty-five (forty-five squared is two thousand twenty-five, and twenty plus twenty-five equals forty-five) and two hundred ninety-seven (eighty-eight thousand two hundred nine splits as eighty-eight plus two hundred nine). The engine uses deterministic BigInt arithmetic and an exhaustive scan of split points, so the result is free of floating-point drift and identical on every run. It never calls the network, never samples randomness, and never depends on the clock.

What a Kaprekar number is and what you see

A positive integer n is a Kaprekar number when the decimal representation of n squared can be divided into two contiguous parts — a left part and a right part — such that those two integers sum exactly to n. The right-hand part may begin with zeros when read as a digit string, but it must not be entirely zero; that rule correctly rejects numbers such as one hundred, whose square is ten thousand and only "works" if a zero right half is allowed.

By long-standing convention the number one is Kaprekar: one squared is one, read as zero plus one. Nine is Kaprekar because eighty-one splits as eight plus one. Forty-five and fifty-five are the best-known two-digit examples; ninety-nine, two hundred ninety-seven, and seven hundred three appear in every standard list.

Ten is composite and positive but not Kaprekar: one hundred cannot be split into non-zero right parts that sum to ten. This checker returns the parsed n, the exact square string, left and right when a valid split exists (otherwise null), and kaprekar true if and only if a valid split was found. Non-Kaprekar positive integers are valid successful responses with kaprekar false; they are not errors.

If you need only the square of an integer without the Kaprekar split test, square it yourself; this page answers the Kaprekar-number question with both parts of the winning split when one exists.

How inputs are read and how the square split stays exact

Optional leading plus signs are allowed for positive values; embedded spaces, hex prefixes, and exponential notation are rejected so a bad cell does not become a wrong flag. Negative integers and zero are rejected because this checker defines Kaprekar numbers on positive integers starting at one. The engine stays inside JavaScript safe integers for the input, which is more than enough for classroom problems, programming contests, and most applied checks on moderately large n.

The algorithm then walks every split index from one through the last digit exclusive: for each index it reads left as the integer prefix and right as the integer suffix, skips suffixes that are all zeros, and accepts the first pair whose sum equals n. There is no floating-point step that could round a near-match into a false Kaprekar claim.

Where Kaprekar checks fit in study, research demos, and code

Students meet Kaprekar numbers when exploring recreational number theory, digit-based properties, and curiosities named after D. R. Kaprekar alongside Kaprekar's constant six thousand one hundred seventy-four from his routine on four-digit rearrangements. Teachers can generate answer keys for worksheets without trusting opaque calculator apps that hide the square-and-split step.

Developers use the same contract to validate sample data for number-theory libraries, to gate property tests on random integer generators, or to pre-check that a seed sits in the Kaprekar class before a demonstration step. Contest practice often needs a fast offline source of Kaprekar answers so solutions can be checked without downloading OEIS tables.

Pair it with a Smith-number checker when you need digit sums of prime factors, with an abundant-number checker when you need divisor-sum classification, and with prime factorization when you need prime powers rather than square splits.

Homework and contest classification

Decide whether positive integers are Kaprekar numbers for worksheets and contest checks by verifying the square-split sum without manual long multiplication.

Teaching square-split curiosities

Show students how digits of n squared recombine into n while they change n live in the browser at no cost.

What does the Kaprekar number checker cost?

It is free in your browser on this page.

What happens if n is below 1?

Kaprekar numbers are defined here only for positive integers n ≥ 1.

How is the Kaprekar test computed?

Square n with exact BigInt arithmetic, then try every decimal split of the square into left and right parts. Accept the first split where the right part is not all zeros and left + right equals n. The number 1 is Kaprekar by convention (0 + 1).

Is the algorithm randomized?

No. It uses deterministic BigInt squaring and an exhaustive split scan. The same n always yields the same square, parts, and kaprekar flag.

Is 100 a Kaprekar number?

No. Although 100² = 10000 and 100 + 00 = 100, the right-hand part is entirely zero, which is not allowed. The checker correctly returns kaprekar false.

Everything on this page is available programmatically. This section is for teams who want to wire it into their own systems; everyone else can just use the tool above.

POSThttps://api.kit.forhosting.com/numth/kaprekar-number

Prefer to automate it? One authenticated POST creates the task; the result comes back by webhook or a signed link. The same capability also runs here on the web, by email and from Telegram — and soon from our app too.

curl -X POST https://api.kit.forhosting.com/numth/kaprekar-number \
  -H "Authorization: Bearer $KIT_KEY" \
  -H "Content-Type: application/json" \
  -d '{"n":45}'
{
  "n": 45
}
{
  "task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
  "type": "numth.kaprekar_number",
  "status": "queued",
  "_links": {
    "result": "/tasks/tsk_…/result"
  }
}

The API is asynchronous: the call returns a task_id immediately and the result arrives by webhook. Polling is capped at 1 req/s per task.

Per request$0.002

Published price — no tokens, no invented credits. A failed task is never charged.

HTTPCodeMeaning
401unauthorizedMissing or invalid API key.
402insufficient_balanceYour balance doesn't cover the task price.
404unknown_typeThat task type doesn't exist.
429rate_limitedToo many requests. Use the webhook instead of polling.

Supply n and the tool returns the exact decimal string of the square, the winning left and right parts when a valid split exists, and a boolean kaprekar flag that is true exactly when such a split is found. Use it free in the browser for homework, contest prep, and OEIS-style exploration, or call the API at $0.002 per successful request when you automate classification pipelines, grading scripts, or teaching demos that need reproducible Kaprekar answers.

What a Kaprekar number is and what the response contains

Missing fields, non-integers, fractions, scientific notation, values outside the safe integer range, and any n below one fail with invalid_input and a clear message.

How inputs are read and how the square split stays exact

The preferred field is n as a JSON integer, but decimal strings and the aliases number or value are accepted so forms, spreadsheets, and query strings can reuse one contract. Internally the square is computed with BigInt so that even when n approaches the safe-integer ceiling the decimal digits of n squared remain exact and never pass through IEEE doubles.

Where Kaprekar checks fit in study, research demos, and code

On this page the work runs entirely in your browser; through the API each successful lookup costs $0.002, failed validation is not charged, and nothing is stored after the response returns. That split — free interactive exploration and a priced, identical API — matches the rest of the KIT tier-A catalog and lets you move from a classroom demo to an automated pipeline without changing the mathematical result.

Deterministic test fixtures

Generate reproducible Kaprekar and non-Kaprekar cases for unit tests, property checks, and CI assertions without embedding static OEIS dumps.

Read the full KIT documentation →