ForHosting KIT · Math

Smith number checker

Tells you whether a composite number's digits add up to the same total as the digits of its prime factors: 22 is a Smith number, since 2 + 2 equals 2 + 1 + 1 from 2 × 11. Both sums are shown. 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
22
You get
Digit sum
4
Factor digit sum
4

The Smith number checker answers a classic recreational number-theory question: for a composite integer n, does the sum of the decimal digits of n equal the sum of the decimal digits of its prime factors counted with multiplicity? Famous examples include twenty-two (two plus two equals two plus one plus one from the factors two and eleven) and twenty-seven (two plus seven equals three plus three plus three). The engine uses deterministic trial division and exact integer digit walks, 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 Smith number is and what you get

A Smith number is a composite integer n such that the sum of its decimal digits equals the sum of the decimal digits of all prime factors of n, with each prime repeated according to its exponent in the factorization. Primes are excluded by definition: the factorization of a prime is the prime itself, so the digit sums would match trivially and the property would be uninteresting. The smallest Smith number is four: digit sum four equals two plus two from the factorization two squared.

Twenty-two is the best-known two-digit example: two plus two equals two plus one plus one from two times eleven. Twenty-seven works because two plus seven equals nine and three cubed contributes three plus three plus three. Six is composite but not Smith: digit sum six versus two plus three equals five.

Non-Smith composites are valid successful responses with smith false; they are not errors. If you need only the prime factorization of an integer without the Smith comparison, use a dedicated factorization tool; this page answers the Smith-number question with both digit sums.

How inputs are read and how the digit sums stay 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 values below two are rejected because Smith numbers are defined on composite positive integers in this checker. The engine stays inside JavaScript safe integers, which is more than enough for classroom problems, programming contests, and most applied checks on moderately large n.

Internally the number is factored by trial division: remove factors of two, then walk odd candidates up through the square root of the remaining cofactor, and finish with any leftover prime greater than one. For each prime power p to the e, the factor digit sum adds e times the decimal digit sum of p. The digit sum of n itself is computed by repeated division by ten.

There is no floating-point step that could round a near-integer into a false Smith claim.

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

Students meet Smith numbers when exploring recreational number theory, digit-based properties, and composite-number curiosities alongside perfect, abundant, and harshad numbers. Teachers can generate answer keys for worksheets without trusting opaque calculator apps that hide the factorization 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 Smith class before a demonstration step.

Contest practice often needs a fast offline source of Smith answers so solutions can be checked without downloading OEIS tables. Pair it with prime factorization when you need only the prime powers, with an abundant-number checker when you need divisor-sum classification, and with a coprime checker when you need pairwise gcd tests rather than digit sums.

Homework and contest classification

Decide whether composite integers are Smith numbers for worksheets and contest checks by comparing digit sums without factoring by hand.

Teaching digit-sum curiosities

Show students how digit sum of n meets digit sum of prime factors while they change n live in the browser at no cost.

What does the Smith number checker cost?

It is free in your browser on this page.

What happens if n is prime or below 2?

Smith numbers are defined only for composite integers n ≥ 4 in practice; this tool rejects n < 2 and all primes.

How is the factor digit sum computed?

Factor n into primes with multiplicity. For each prime power p^e, add e times the sum of the decimal digits of p. Compare that total to the digit sum of n.

Is the algorithm randomized?

No. It uses deterministic trial division and exact digit sums. The same n always yields the same factors, digit sums, and smith flag.

How is this different from prime factorization?

Factorization returns the prime powers of one integer. This tool factors a composite and reports whether its digit sum equals the digit sum of those factors with multiplicity.

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/smith-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/smith-number \
  -H "Authorization: Bearer $KIT_KEY" \
  -H "Content-Type: application/json" \
  -d '{"n":22}'
{
  "n": 22
}
{
  "task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
  "type": "numth.smith_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 a composite n and the tool returns the digit sum of n, the digit sum of the prime factorization, the prime-power factors, and a boolean smith flag that is true exactly when those two sums match. 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 Smith answers.

What a Smith number is and what the response contains

This checker therefore rejects primes and any n below two with invalid_input, and only classifies composites. The response always includes the parsed n, digit_sum, factor_digit_sum, the ascending list of prime powers as base and exponent pairs, and smith true if and only if the two sums are equal. Missing fields, non-integers, fractions, scientific notation, values outside the safe integer range, n below two, and primes fail with invalid_input and a clear message.

How inputs are read and how the digit sums stay 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.

Where Smith 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 Smith and non-Smith composites for unit tests, property checks, and CI assertions without embedding static OEIS dumps.

Read the full KIT documentation →