ForHosting KIT · Math

Distinct parts partition count

The number 5 splits into different parts in 3 ways: 5, 4+1 and 3+2. Enter any whole number from 0 to 5000 and get the exact count of its distinct-part partitions, however many digits it has. 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
10
You get
Value
10
Quantity
10
Q
10

The distinct-parts partition function q(n) answers a classic number-theory question: in how many ways can you write a non-negative integer n as a sum of positive integers when every summand appears at most once and the order of summands does not matter? For example, 5 equals 5, 4+1, and 3+2, so q(5) equals three; 6 has four distinct-part partitions and 10 has ten. This count is different from the unrestricted partition function p(n), which allows repeated parts such as 2+2 or 1+1+1. Distinct-part partitions appear in generating-function identities, Euler's theorem equating them with odd-part partitions, olympiad problems, and contest dynamic-programming drills. This capability accepts a non-negative integer n and returns the exact q(n) as a decimal string computed with BigInt 0-1 knapsack-style dynamic programming, so values beyond ordinary safe-integer limits stay correct digit for digit. Negative n is rejected with a clear validation error instead of a silent zero or a wrong answer.

How partitions into distinct parts are defined and counted

A partition of a non-negative integer n into distinct parts is a way of writing n as a sum of positive integers in which no part is repeated and the order of summands is irrelevant. By convention q(0) equals one, counting the empty partition of zero. Small textbook values are q(1)=1 (namely 1), q(2)=1 (namely 2), q(3)=2 (3 and 2+1), q(4)=2 (4 and 3+1), q(5)=3 (5, 4+1, 3+2), q(6)=4, and q(10)=10.

The ordinary generating function for the sequence is the infinite product over k greater than or equal to one of one plus x to the k, which encodes that each positive integer may appear either zero times or exactly once as a part.

A practical algorithm used in software is the classic 0-1 knapsack style dynamic program: initialize an array with one way to make sum zero, then for each part size from one through n, walk the remaining sum array from n down to that part size and add the ways that exclude the part into the ways that include it. Descending order ensures each part is used at most once, so unrestricted multi-use of a part never occurs.

Related but different objects include unrestricted partitions p(n), where parts may repeat; compositions, where order matters; set partitions counted by Stirling numbers of the second kind; and odd-part-only partitions, which Euler proved are equinumerous with distinct-part partitions for every n. This implementation never uses floating-point approximation, Monte Carlo sampling, or external tables: it fills a one-dimensional BigInt array so every digit is correct. The path is fully deterministic—no random seeds, no clocks, no network, and no model drift—so the same n always yields the same string.

Where distinct-part partitions show up in real work

Number-theory courses and programming contests constantly ask how many partitions of n use pairwise distinct summands, how that count compares with unrestricted p(n), or whether a table of small values matches Euler's identity with odd-part partitions. Algorithm designers use distinct-part counts when analyzing 0-1 subset-sum style state spaces, counting combinations of unique resource sizes that total a budget, or sizing DP tables whose dimensions track part sizes used at most once.

Combinatorics and generating-function lessons connect q(n) to the product of one plus x to the k and to Rogers–Ramanujan type restricted identities; educators often list the distinct partitions of a small n and then ask for the count alone. Interview prep and olympiad training frequently need a single reliable q(n) without hand-maintaining tables or accidentally counting compositions or unrestricted partitions.

If you later need unrestricted p(n), compositions where order matters, set partitions via Stirling numbers of the second kind, or an explicit listing of every distinct-part partition rather than the count, treat those as separate search intents rather than overloading this landing. Keep n inside the documented bound so free-tier latency stays predictable, and prefer string consumers for the returned value because q(n) eventually leaves the safe-integer range for large arguments.

Number-theory homework and contests

Compute exact q(n) for olympiad problems, discrete-math exercises, and automated answer keys that ask for partitions into distinct parts.

Euler identity classroom checks

Verify classic values such as q(5)=3 and q(10)=10 when teaching generating functions or comparing distinct-part and odd-part counts.

What is the distinct-parts partition function q(n)?

q(n) counts the ways to write n as a sum of positive integers when no part repeats and order does not matter. For example q(5)=3 and q(10)=10.

How is this different from unrestricted partitions p(n)?

Unrestricted p(n) allows repeated parts (so 2+2 counts for 4). Distinct-part partitions forbid repeats, so 4 has only two such partitions: 4 and 3+1.

Why is the value a string instead of a number?

Distinct-part partition numbers grow past JavaScript safe integers for large n. Decimal strings keep every digit exact.

What does it cost?

The browser tool is free and runs locally.

How many distinct-part partitions does 5 have?

It has 3: 5 on its own, 4+1 and 3+2. Sums such as 2+2+1 or 1+1+3 do not count, because a part may not appear twice, and 4+1 and 1+4 are the same partition.

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/distinct-partitions

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

The free browser tool and the paid API share one pure function, so classroom demos and automated pipelines never diverge on the same n.

How partitions into distinct parts are defined and counted

Declared bounds keep n between zero and five thousand inclusive, which keeps worst-case latency suitable for a free in-browser tool and a lightweight Worker path while still covering contest, classroom, and pipeline needs for exact distinct-part counts.

What you send and what you get back

The integer n must lie from zero through five thousand inclusive. Error messages name the offending field and the rule that failed so form clients and scripts can correct the input without guessing. On success the response always includes the normalized n, value and count and q as the same exact decimal string for q(n), and a short formula string such as q(5) for display. Provide a required integer n under the field n (aliases number, value, or N). Missing fields, non-integers, decimals, and any negative n are rejected with invalid_input and are not charged. Example checks: n equals five yields count three; n equals ten yields count ten; n equals zero yields count one; n equals six yields count four; n equals three yields count two; n equals negative three yields invalid_input because the distinct-parts function is not defined for negative arguments in this product rule; n equal to a decimal or a non-numeric string also yields invalid_input. Pricing for successful API calls is the published base of $0.002 per item; validation failures do not consume prepaid balance.

Where distinct-part partitions 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.

0-1 knapsack and subset-sum analysis

Validate distinct-part-count fixtures inside integer DP pipelines that use each part size at most once without floating-point tables.

What happens if n is negative?

The request fails with invalid_input. This calculator requires n ≥ 0; negative n is rejected and not charged.

Read the full KIT documentation →