ForHosting KIT · Math

Alternating digit sum calculator

For 918082 the alternating digit sum is 22, a multiple of 11, so the number divides by 11 exactly. Enter any non-negative whole number to see its digits, the signed total and the remainder. 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
918,082
You get
Digits
9, 1, 8, 0, 8, 2
Alternating sum
22
Residue mod 11
0

The alternating digit sum adds and subtracts successive decimal digits, beginning with addition at the leftmost digit. Its residue modulo eleven is the same as the original integer's residue up to a harmless sign convention, which makes it a compact divisibility test: the number is divisible by eleven exactly when the alternating sum is a multiple of eleven. Enter any non-negative safe integer to receive its digits, signed alternating total, normalized residue from zero through ten, and a direct divisibility result in one deterministic response.

How the alternating digit sum is calculated

Read the decimal digits from left to right. Add the first digit, subtract the second, add the third, and continue switching signs until every digit has been used. For 918082, the calculation is 9 minus 1 plus 8 minus 0 plus 8 minus 2, which equals 22.

Starting from the rightmost digit instead would sometimes reverse the sign, depending on the number of digits, but it would not change whether the result is a multiple of eleven. This capability deliberately starts at the left because that convention is simple to explain and reproduce. Zero is represented by the single digit zero and therefore has an alternating sum of zero.

Only ordinary base-ten notation is used; there is no optional radix, separator, decimal point, or sign included among the digits. Processing is a bounded pass over at most sixteen digits, so the calculation is exact, quick, and deterministic.

Understanding the residue and response

The raw alternating total can be negative. For example, an alternating sum of minus 2 has normalized residue 9 because minus 2 and 9 represent the same congruence class modulo eleven. A zero residue does not mean the input itself is zero; it means the alternating total is a multiple of eleven, including totals such as minus 22, 0, 11, or 33.

The response also returns the validated n and the digits array so callers can audit the calculation rather than trusting a bare yes-or-no answer.

Using the divisibility rule correctly

The rule works because ten is congruent to minus one modulo eleven. Successive decimal place values therefore alternate between plus one and minus one when reduced modulo eleven, so combining the digits with alternating signs preserves the number's residue, possibly with the overall sign reversed. That mathematical fact makes this useful for classroom demonstrations, worksheet checking, validation pipelines, and puzzle solutions.

It is a divisibility test, not a general-purpose checksum: many different numbers share the same residue, so the result cannot establish identity, detect every transcription error, or replace a cryptographic hash. It also does not divide the input or list factors.

Verify classroom exercises

Show the ordered digits and signed total so students and teachers can audit every alternating step.

Validate numeric records

Apply a deterministic modulo-eleven precheck to identifiers in scripts while retaining an explainable intermediate value.

What is an alternating digit sum?

It is the result of adding and subtracting successive decimal digits. This calculator adds the leftmost digit, subtracts the next, and continues alternating signs.

Are negative inputs supported?

Provide a non-negative integer no larger than 9007199254740991.

How do I check whether a number is divisible by 11?

Add and subtract its digits in turn from the left. For 918082 that is 9 − 1 + 8 − 0 + 8 − 2, which gives 22. The number is divisible by 11 exactly when this total is a multiple of 11.

Why can the alternating sum be negative?

Because every second digit is subtracted, the total can drop below zero. A total of minus 2 still gives a remainder of 9, since both belong to the same class when you divide by 11.

Does it matter whether I start from the left or the right?

Starting from the right can flip the sign of the total, depending on how many digits there are, but it never changes whether the result is a multiple of 11. This tool always starts from the left.

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

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.

How the alternating digit sum is calculated

The response preserves the digit order and reports that signed value as alternating_sum.

Understanding the residue and response

To make downstream comparisons convenient, residue_mod_11 normalizes that total into the range zero through ten. The boolean is_divisible_by_11 is true precisely when that normalized residue is zero. Inputs may use n or the documented aliases number, value, and integer. Numeric strings containing only decimal digits and an optional leading plus sign are accepted by the shared solver, while decimals, scientific notation strings, missing values, booleans, negative values, and integers beyond JavaScript's safe range produce invalid_input.

Using the divisibility rule correctly

Use is_divisible_by_11 when a simple decision is enough, and retain alternating_sum when you want to show the work or continue a modular argument. The browser calculation runs from the same pure solver as the API contract. API pricing is $0.002 per successful item, and validation failures return an error instead of a plausible-looking result.

Check divisibility by eleven

Test a non-negative integer without long division and receive both the residue and an explicit boolean result.

How does it test divisibility by eleven?

An integer is divisible by eleven exactly when its alternating digit sum is a multiple of eleven, which appears as residue_mod_11 equal to zero.

Can the alternating sum be negative?

Yes. alternating_sum keeps its sign, while residue_mod_11 converts it to a canonical value from zero through ten.

What does the calculation cost?

The browser calculator is free. Each successful API item costs $0.002; invalid input returns an error.

Read the full KIT documentation →