Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Given a value n and number of parts d. Each part has max and min values it can have.

Is it possible to divide n in d parts fullfilling the max and min value criteria ? Example

d=2 n=5

Part 1 range-> 0 to 1 Part 2 range -> 3 to 5. Answer is YES . Part1 can have value 1 and Part2 can have value 4

share|cite|improve this question

This clearly depends on the given ranges. Let's fix some notation: We have a given number $n$, which is to be split into $d$ parts, where the $i$-th part has to have a value between $\ell_i$ and $u_i$ (inclusive).

Your example would be $n = 5$, $d = 2$, $\ell_1 = 0$, $u_1 = 1$, $\ell_2 = 3$, $u_2 = 5$.

Another example would be $n = 20$, $d = 3$, $\ell_1 = \ell_2 = \ell_3 = 0$, $u_1 = 5$, $u_2 = 6$, $u_3 = 7$. This does not have a solution: Assume that $p_1, p_2$ and $p_3$ are given such that $0 \le p_1 \le 5$,$0 \le p_2 \le 6$, $0 \le p_3 \le 7$. Then we clearly have $p_1 + p_2 + p_3 \le 5 + 6 + 7 = 18 < 20$, so $p_1 + p_2 + p_3 \neq n$.

More generally, we can divide $n$ in $d$ parts as above if $\sum_{i=1}^d \ell_i \le n \le \sum_{i=1}^d u_i$.

share|cite|improve this answer
thank you your solution is good – Ashesh Vidyut May 11 '13 at 13:50

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.