How to solve summation (t+i)!/i! where i is from 1 to n.

39 Views Asked by At

I am solving a coding question and term is:

(t+1)!+(t+2)!/2!+......(t+n)!/n!
1<=t<=1000
1<=n<=10^11

and answer should be in modulo 1000000007 (10^9+7).

So I wrote code in cpp to find (t+1)!. So I am having (t+1)!. Now what are the approaches to solve it?

  • I don't want to find factorial of each term because is expensive. I want to use the (t+1)! term for rest of the terms.
  • I want to find modulo of each individual term and then find modulo of whole term using modulo property.