|  | 
|  | 
| back to board | A question... Posted by Alexey  27 Jun 2006 15:46g(x,y)=((y-1)*x^5+x^3+3*x-x*y+7*y) mod MThe result is in 0..M-1
 But while counting it I have problems with type.
 How to make it work with big values (For expample, If x=1000000)?
 
 Thanks.
Re: A question... Posted by Sid  27 Jun 2006 17:35Everybody knows...x*x mod m = ((x mod m) * (x mod m))mod m
 x+x mod m = ((x mod m) + (x mod m))mod m
Yeah, but... Posted by Alexey  27 Jun 2006 17:58You mean that((y-1)*x^5) mod M=(((y-1) mod M)*(x mod M)^5) mod M.
 But x mod M can be 9972 (M=9973) and
 9972^5 has 14 digits. It's too much.
 I know another formula...
 (x^y) mod M=((((x mod M)*x) mod M)*x) Mod M... y times.
 But it gets incorrect answer...
 
 Can U give me answers for these tests?
 1) 9973
 2) 19946
 3) 29919
 4) 8
 
 Thanks.
 
 Edited by author 27.06.2006 18:49
 | 
 | 
|