Possible Duplicate:
Need help in mod 1000000007 questions
I have a set of numbers for which i want to compute total product modulo 1000007. e.g if my array contains 1000 numbers then i need to compute the following.
int product = 1;
for(int i=0;i<Array_Max;i++)
product = product * Array[i]
then product modulo 1000007 = ?
Is there any algorithm to optimize the above pseudo code ? Right now i am unable to store the product because of overflow.
Any suggestion appreciated.