I need an algorithm to calculate the number of ways of expressing a number N as sum of numbers inside the interval [a, b]

  • 1
    $\begingroup$ What for? What have you tried? Is there a target runtime? $\endgroup$
    – Raphael
    Jun 8, 2012 at 12:17

1 Answer 1


What you want is the number of integer partitions restricted to the interval $[a,b]$. I suggest you take a look at the approaches to count all partitions (check references and external links of the article) and adapt it to your needs.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.