Get the number of compositions with restrictions The number of compositions of $n$ is $2^{n-1}$.
For $n=5$, the number of compositions is $2^{5-1}=16$


*

*5

*4 + 1

*3 + 2

*3 + 1 + 1

*2 + 3

*2 + 2 + 1

*2 + 1 + 2

*2 + 1 + 1 + 1

*1 + 4

*1 + 3 + 1

*1 + 2 + 2

*1 + 2 + 1 + 1

*1 + 1 + 3

*1 + 1 + 2 + 1

*1 + 1 + 1 + 2

*1 + 1 + 1 + 1 + 1


What if I want only the count for compositions where all the parts are greater than a value $k$ ($k=2$ in my example, and the kept compositions are the bold ones) ?

The recursion for the unrestricted compositions is:
$F_0=1$ and $F_n=\sum\limits_{j=0}^{n-1} F_j$, it is easy to show with induction that this is equal to $2^{n-1}$.
The recursion for the "restricted" compositions in which every block is in $[a,b]$ is $F_0=1$ and $F_n=\sum\limits_{j=a}^{\min(n,b)}F_{n-j}$. This allows you to get $F_n$ in time $\mathcal O(n(b-a+1) )$, I don't know if this is fast enough.
some c++ code:
#include <bits/stdc++.h>
using namespace std;

const int MAX=10010; // size of array
int F[MAX]; // this array stores the results

int main(){
    int a,b,n;
    scanf("%d %d %d",&a,&b,&n); // this takes the input of a,b,n
    F[0]=1;
    for(int i=1;i<=n;i++){// we recursively udate the value
        for(int j=a;j<=b && j<=i;j++){
            F[i]+=F[i-j]; // we add F[i-j] to F[i];
        }
    }
    printf("%d\n",F[n]); //prints the result
}

