ForHosting KIT · Math

Harshad number checker

18 is a Harshad number: its digits add up to 9, and 18 divided by 9 is exactly 2. Enter any positive integer to see its digits, their sum and whether that sum divides it, handy for contest problems and digit-sum homework. 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
18
You get
Digits
1, 8
Digit count
2
Digit sum
9
Quotient
2

A Harshad number—also called a Niven number—is a positive integer that is divisible by the sum of its own decimal digits. The name Harshad comes from Sanskrit for “joy-giver,” and the Niven name honors mathematician Ivan Niven; both labels point to the same divisibility property. Students meet these numbers in contest problems and homework on digit sums; teachers need a deterministic oracle that shows digits, sum, and quotient; engineers occasionally use the test as a lightweight structural filter on serial identifiers. This checker takes a single positive integer n, expands its decimal digits, sums them, tests whether that sum divides n, and returns the integer quotient when it does.

How the Harshad (Niven) test and quotient are computed

Start with a positive integer n written in base ten. Extract each place-value digit by repeatedly taking n modulo ten and dividing by ten with integer division, then reverse the collected remainders so they appear most-significant first. Sum those digit values to obtain s, often written s(n) or sod(n) in textbooks.

By definition n is Harshad—equivalently Niven—if and only if s divides n with no remainder, that is n mod s equals zero. When the test passes, the Harshad quotient is the ordinary integer division n divided by s; when it fails, there is no integer quotient under this definition and the field is returned as null so clients can branch without inventing a fractional value.

Classic examples: eighteen has digits one and eight, sum nine, and eighteen divided by nine equals two, so it is Harshad with quotient two; nineteen has digits one and nine, sum ten, and nineteen is not divisible by ten, so it is not Harshad. One is Harshad because the single digit one divides one with quotient one. Powers of ten such as ten and one hundred have digit sum one and are therefore always Harshad.

Where Harshad checks show up in real work

Classroom lessons on divisibility rules for three and nine already use the decimal digit sum; Harshad numbers extend that intuition to the full divisibility predicate and give students a named family to explore. Product and operations teams sometimes apply lightweight structural filters on ticket codes, batch identifiers, or generated serials when a full Luhn or cryptographic checksum would be heavier than needed; a deterministic Harshad flag plus quotient is a simple gate that can be audited offline.

Use the free browser tool for homework and quick sanity checks, then call the identical contract from scripts when you need bulk verification. If you later need only the digit sum without the Harshad predicate, range enumeration of Harshad numbers, or multi-base expansions, treat those as separate search intents rather than overloading this landing.

Digit-sum divisibility teaching

Show students the ordered digits, their sum, and the divide-or-fail outcome so the Niven definition is concrete, not abstract.

Lightweight serial structure checks

Apply a deterministic Harshad flag and quotient to ticket or batch identifiers in pipelines that need a simple additive gate.

What is a Harshad or Niven number?

A positive integer divisible by the sum of its decimal digits. For example 18 has digit sum 9 and 18÷9=2, so 18 is Harshad (Niven).

What does the quotient field mean?

When the sum does not divide n, quotient is null.

Is base ten the only base supported?

Yes. This checker uses decimal digits only, which matches the usual Harshad/Niven search intent. Other bases are out of scope here.

What does it cost?

The browser tool is free and runs locally.

Is 18 a Harshad number?

Yes. Its digits 1 and 8 add up to 9, and 18 divided by 9 is 2 with no remainder. The checker shows the digits, the sum of 9 and the quotient of 2.

Why is 11 not a Harshad number?

Its digits 1 and 1 add up to 2, and 11 is odd, so it cannot be divided by 2 without a remainder. When the sum does not divide the number, no quotient is shown.

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/harshad-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/harshad-number \
  -H "Authorization: Bearer $KIT_KEY" \
  -H "Content-Type: application/json" \
  -d '{"n":18}'
{
  "n": 18
}
{
  "task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
  "type": "numth.harshad_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.

min_n1
max_n9007199254740991
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.

The browser tool and the API share one pure function, so interactive checks and automated pipelines never silently diverge.

What you send and what you get back

Zero and negative integers fail because the classical Harshad and Niven definition applies only to positive integers; the error message states that n must be at least one so form clients and scripts can correct the input without guessing. Because the engine is pure parse work, the same n always produces the same object with no model drift and no stored state between calls. Provide a required positive integer under the field n, or the aliases number, value, or integer. Values that are missing, non-integers, less than one, or larger than the safe-integer maximum are rejected with invalid_input and are not charged. On success the response includes the normalized n, digits as an array of decimal digit values in most-significant-first order, digit_count as the length of that array, digit_sum as their total, is_harshad as a boolean, and quotient as either the integer n divided by digit_sum when is_harshad is true or null when the sum does not divide n. Example checks: n equals eighteen yields digits one and eight, digit_sum nine, is_harshad true, quotient two; n equals nineteen yields digit_sum ten, is_harshad false, quotient null; n equals twelve yields digits one and two, sum three, quotient four.

Where Harshad checks show up in real work

Because this capability is a pure parse engine, API pricing is the published base of $0.002 per successful item and failed validation does not consume balance.

Contest and homework fixtures

Verify whether n is Harshad and capture the exact quotient for olympiad problems and classroom answer keys.

Why is n less than 1 rejected?

The classical definition covers positive integers only. Zero and negatives return invalid_input with a message that n must be at least 1.

Read the full KIT documentation →