I need To Find The Summation Of the Below Series:
(n+1-1)C1+(n+2-1)C2+…+(n+k-1)CK(Hint:(n+k-1)Ck=(n+k-1)C(K)+(n+k-1)C(k-1))
The ans should be printed as Modulo m
Here n=Len and k=N and m=1000003
#include<stdio.h>
#define M 1000003
int main(){
int t=0;
long long int sum=0,L,R,N,init=0,i=0,Len=0;
scanf("%d",&t);
while(t-- > 0){
scanf("%lld%lld%lld",&N,&L,&R);
Len=R-L+1;
if(R==L){
printf("%lld\n",N%M);
}
else if(N<=Len){
init=Len%M;
sum=init;
for(i=2;i<=N;i++){
//I think beacuse of improper placements of modulo m getting wromg ans
init=((((init%M)*((Len%M+i%M-1)%M))%M)/(i%M))%M;
//printf("%lld",init);
sum=(sum%M+init%M)%M;
}
printf("%lld\n",sum);
sum=0;
}
}
//getch();
return 0;
}
I am getting wrong ans because of improper placements of modulo