ForHosting KIT · Developer Utilities

Digit factorial chain length calculator

A digit factorial chain begins with a non-negative integer, replaces it with the sum of the factorials of its decimal digits, and repeats that operation until a value appears for the second time.

● BetaFree · in your browser
Use it from WebAPIEmailTelegramApp soon

This calculator returns the number of distinct values visited before that first repetition. It provides a quick, exact way to explore a classic number-theory process without manually evaluating every factorial and checking the growing sequence for a cycle.

How a digit factorial chain is formed

Start with the non-negative integer you want to examine. Separate its decimal digits, take the factorial of each digit, and add those factorials together. The result becomes the next value, and the same rule is applied again. For example, starting from 69 gives 6! + 9!, which equals 363600. Processing the digits of that result produces the following value, and the chain continues in exactly the same way. The calculator remembers every value it encounters. As soon as the next result has already appeared, the process has entered a cycle and the calculation stops. The reported length counts only distinct visited values, including the starting number, but does not count the repeated occurrence a second time. This convention makes the result precise and useful when comparing starting values. Zero is handled as a decimal digit in its own right, so 0! equals 1. No rounding or approximation is involved at any stage of the calculation.

Understanding the returned length

The result is a single length rather than the full intermediate sequence. It answers the central question: how many distinct terms occur before repetition begins? Consider a chain that reaches a value seen several steps earlier. Every term up to its first appearance contributes one to the length, while the second appearance signals the stopping point and contributes nothing further. This definition covers both fixed points and longer cycles. If a value maps directly to itself, it forms a chain of length one when used as the starting value. If the start first travels through several other values and eventually reaches that fixed point, all distinct values on the route are counted. Different starting integers may merge into the same later path but still have different lengths because their unique prefixes differ. The algorithm uses exact safe-integer arithmetic, validates the input before starting, and records membership explicitly, so its stopping decision does not depend on a guessed iteration limit or a mathematical shortcut.

Using the calculator reliably

Enter one non-negative safe integer in the n field. Whole numbers are required because decimal fractions do not have the intended sequence of decimal digits for this operation, and negative numbers are outside the capability's defined domain. The browser version is convenient for individual experiments, classroom demonstrations, and checking a result while reading about factorial chains. The API is useful when a program needs to compare many chosen inputs, build exercises, or verify results produced elsewhere; each request is priced at $0.002. The computation is deterministic: the same integer always returns the same length, with no network calls, randomness, current time, or external data involved. Although the repeated transformation may initially produce a larger number, digit-factorial sums quickly enter a finite bounded region, so recording previously visited values gives a natural termination test. For reproducible work, retain both the original input and returned length, and state that the repeated occurrence itself is excluded whenever you compare these results with another source that may use different wording.

Explore number-theory sequences

Measure how long a chosen starting value travels before its digit factorial process reaches a repeated term.

Check educational exercises

Verify a manually worked digit factorial chain and confirm that its distinct terms were counted consistently.

Compare selected starting values

Call the API for a set of integers and compare their chain lengths in a reproducible experiment.

What exactly does the length count?

It counts distinct values from the starting integer through the last new value before the first repetition. The repeated occurrence is not counted again.

Is the starting number included?

Yes. The starting integer is the first distinct value in the chain and contributes one to the returned length.

How is the digit zero treated?

Zero contributes 0!, which equals 1. A starting value of zero therefore proceeds to one.

Can n be negative or fractional?

No. The input must be a non-negative safe integer. Negative numbers and fractional values return an invalid-input error.

What does one API request cost?

One API request costs $0.002. You can also run the calculator directly in your browser.

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-factorial-chain

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

Read the full KIT documentation →