Restricted Partition Calculator
Enter an integer n and the number of parts k to count the partitions.
Result
How it is calculated
The tool counts the partitions of n into exactly k positive parts, where order does not matter (so 7+2+1 and 1+2+7 are one partition). It fills a table with the recurrence p(n, k) = p(n − 1, k − 1) + p(n − k, k) and starts from p(0, 0) = 1. The first term covers partitions that contain a part equal to 1 (remove it), the second covers partitions whose parts are all at least 2 (subtract 1 from every part). Inputs are rounded to whole numbers, so 3.6 is treated as 4. n must be between 0 and 200 and k must not exceed n, otherwise there is no result. With k = 0 and n above 0 the count is 0.
Worked example
How many ways can 10 be written as a sum of exactly 3 positive integers? The recurrence gives p(10, 3) = p(9, 2) + p(7, 3) = 4 + 4 = 8. Listing them confirms it: 8+1+1, 7+2+1, 6+3+1, 6+2+2, 5+4+1, 5+3+2, 4+4+2 and 4+3+3. Counts grow quickly: for n = 200 and k = 100 the tool returns 190,569,292.
Common mistakes
- Counting ordered sums: 7+2+1 and 1+2+7 are the same partition here, so a hand count of compositions will be much larger.
- Confusing p(n, k), exactly k parts, with the partitions of n into at most k parts, which is a larger number.
- Allowing zero as a part: every part must be at least 1.
- Entering k larger than n, which cannot be split into that many positive parts and returns no result.
- Entering a decimal such as 3.6 and expecting an error: the tool rounds it to 4 and answers for that.
About this calculator
p(n,k) counts the number of ways to write a positive integer n as a sum of exactly k positive parts, ignoring order. It's computed with the classic recurrence p(n,k) = p(n−1,k−1) + p(n−k,k), which splits on whether the smallest part equals 1 or every part can be reduced by 1.
This restricted count is a building block for the broader partition function p(n) and for generating-function techniques in number theory and combinatorics. It's used by math students, competitive programmers, and researchers working on integer partition problems, where counting the ways a number breaks into pieces of a fixed count comes up constantly.
Was this helpful?
You can pick up to 3 reactions.
Popular calculators
Loan Calculator
Monthly payment, total interest and full amortization schedule.
Percentage Calculator
Percent change, percent of, and ratio calculations.
Discount Calculator
Calculate final price, savings, and discount amount.
BMI Calculator
Body mass index from height and weight (metric or imperial).
Age Calculator
Compute your exact age in years, months and days from a birth date.
Compound Interest Calculator
Calculate the final amount and interest earned with compounding.
All Calculators
- Loan Calculator
- Profit Calculator
- Discount Calculator
- BMI Calculator
- Percentage Calculator
- Ideal Weight Calculator
- Age Calculator
- Pregnancy Due Date Calculator
- Compound Interest Calculator
- BMR Calculator (Basal Metabolic Rate)
- Tip Calculator
- Fuel Cost Calculator
- Date Difference Calculator
- Sleep Cycle Calculator
- Daily Water Intake Calculator
- Simple Interest Calculator
- Heart Rate Zones Calculator
- Running Pace Calculator
- Pet Age Calculator
- Calories Burned Calculator
- Macro Calculator
- TDEE Calculator (Total Daily Energy Expenditure)
- Waist-to-Hip Ratio Calculator
- Honor Roll Calculator
- One Rep Max (1RM) Calculator
- Ovulation Calculator
- Electricity Cost Calculator
- Unit Price Calculator
- Savings Goal Calculator
- Break-Even Point Calculator
- Paint Calculator
- Course Grade Average Calculator
- Business Days Calculator
- Time Duration Calculator
- Fuel Economy Calculator
- Temperature Converter
- Tile Calculator
- Aspect Ratio Calculator
- Roman Numeral Converter
- Goal Weight Timeline Calculator
- Salary Converter (Hourly to Annual)
- Credit Card Validator (Luhn)
- Body Surface Area (BSA) Calculator
- Feels-Like Temperature Calculator
- Ohm’s Law Calculator
- PPI (Pixel Density) Calculator
- Molar Mass Calculator
- Zodiac Sign Calculator (Western + Chinese)
- IBAN Validator
- Shoe Size Converter
- Country Info & Dialing Code Lookup
- Time Zone Difference (World Clock)
- CAGR (Compound Annual Growth Rate) Calculator
- Rule of 72 Calculator
- Blood Alcohol Content (BAC) Calculator
- Lean Body Mass (LBM) Calculator
- Pythagorean Theorem Calculator
- Speed Converter
- Download Time Calculator
- Date Calculator (Add/Subtract)
No calculators found
Comments (1)
Two quick checks help you trust a result. Adding p(10, k) for k = 1 to 10 gives 1, 5, 8, 9, 7, 5, 3, 2, 1 and 1, which total 42, the number of all partitions of 10. And the count for at most 3 parts is the sum of the first three, 14, rather than the 8 for exactly 3. Inputs go up to n = 200. Are you using this for a puzzle, a programming contest or a proof?