I want to compute the function H(n) where
H(0)=0;
H(i)=H(i-1)×A+Ci mod B;
10<=A,B<=10^15;
C is an array of n elements
But it is taking too much time...any better way of doing this..Please help
public BigInteger H(int no)
{
if(no>0)
{
bi=H(no-1);
bi=bi.multiply(BigInteger.valueOf(A));
bi=bi.add(BigInteger.valueOf(c[no-1]));
bi=bi.remainder(BigInteger.valueOf(B));
return bi;
}
return BigInteger.ZERO;
}