ForHosting KIT · Math

Digit sum calculator

The digits of 12345 add up to 15. Enter any integer, choose a base from 2 to 36 when you need one other than ten, and see every digit together with their total. 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
12,345
You get
Abs n
12,345
Base
10
Digits
1, 2, 3, 4, 5
Digit count
5

The digit sum of an integer is the total of its place-value digits in a chosen numeral base.

How the digit expansion and sum are computed

Write a non-negative integer in base b by repeatedly dividing by b and recording remainders. Each remainder is a digit between zero and b minus one inclusive; reading the remainders from last to first yields the usual most-significant-digit-first notation. The digit sum is simply the arithmetic total of those remainders, independent of order.

For base ten, 12345 becomes the digits one, two, three, four, five and the sum fifteen. For base two, the same algorithm produces the binary bits and their Hamming-weight-style sum. Zero is treated as a single digit zero so the sum is zero rather than an empty total.

The implementation stays inside JavaScript safe integers so every divmod step is exact, with no floating-point drift and no dependency on external libraries or network calls.

Where digit sums show up in real work

Classroom divisibility rules for three and nine rest on the decimal digit sum modulo nine equaling the number modulo nine; teachers need a deterministic oracle that shows the intermediate digits, not only a black-box total. Olympiad and programming-contest problems often ask for the sum of digits after writing n in base b, or for repeated digit sums that begin with a single expansion. Product teams use lightweight additive checks on serial numbers, ticket codes, and batch identifiers when a full Luhn or cryptographic checksum would be overkill.

Use the browser tool for homework and quick sanity checks, then call the identical contract from scripts when you need bulk verification. If you later need the digital root (repeated summing until a single digit) or modular checksums such as Luhn, treat those as separate intents rather than overloading this digit-sum landing.

Divisibility and homework checks

Verify decimal digit sums for rules of three and nine, with the full digit list returned so students can audit each step.

What is a digit sum?

The digit sum of an integer is the total of its place-value digits in a chosen base. For 12345 in base 10 the digits are 1+2+3+4+5 and the sum is 15.

Which bases are supported?

Bases from 2 through 36. Base 10 is the default.

How are negative numbers handled?

The absolute value is expanded. Digit sum of −123 equals digit sum of 123; the sign does not change place-value digits here.

Does this compute the digital root?

No. It returns a single expansion and its sum. Repeated summing until one digit (the digital root) is a different task.

What does it cost?

The browser tool is free and runs locally.

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/digit-sum

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/digit-sum \
  -H "Authorization: Bearer $KIT_KEY" \
  -H "Content-Type: application/json" \
  -d '{"n":12345}'
{
  "n": 12345
}
{
  "task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
  "type": "numth.digit_sum",
  "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_base2
max_base36
max_abs_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.

Students use it for divisibility rules, contest programmers for checksum-style reductions, and engineers when validating that a payload or serial number matches a simple additive check. This calculator expands your integer in base ten by default—or in any base from two through thirty-six—then adds every digit value.

How the digit expansion and sum are computed

Negative inputs use the absolute value: the sign does not alter place-value digits in this definition, which matches how divisibility rules and most homework sheets treat digit sums.

What you send and what you get back

Optionally set base to an integer from two through thirty-six; when omitted, base defaults to ten for ordinary decimal digit sums. Example checks: n equals 12345 in base ten yields digits one through five and sum fifteen; n equals two hundred fifty-five in base sixteen yields digits fifteen and fifteen with sum thirty; n equals zero yields a single zero digit and sum zero. Provide a required integer n under the field n, or the aliases number, value, or integer. Values that are missing, non-integers, out of the safe range, or that request a base below two or above thirty-six are rejected with invalid_input and are not charged. On success the response includes the normalized n, abs_n equal to the absolute value used for expansion, the effective base, digits as an array of non-negative integers in most-significant-first order, digit_count as the length of that array, and digit_sum as their total.

Where digit sums show up in real work

Because this capability is a pure parse engine, the same n and base always produce the same JSON with no model drift and no stored state. API pricing is the published base of $0.002 per successful item; failed validation does not consume balance.

Contest problems in arbitrary bases

Compute the sum of digits of n written in base b for olympiad and programming-contest fixtures without writing a local helper.

Lightweight serial and code checks

Apply a simple additive digit total to ticket codes or batch identifiers in pipelines that need a deterministic, chargeable API shape.

Read the full KIT documentation →