On Sat, Oct 22, 2011 at 9:04 PM, Mad Coder <imamadco...@gmail.com> wrote:
> > > Can anyone explain why ((n%p)*(m%p))%p will give wrong answer ? > > Lets say, n = 10^15 , m = 10^15 and p = 10^18 So, n%p = 10^15 m%p = 10^15 And the intermediate result (n%p)*(m%p) will overflow the long long range. > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To post to this group, send email to algogeeks@googlegroups.com. > To unsubscribe from this group, send email to > algogeeks+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/algogeeks?hl=en. > -- Aamir Khan | 3rd Year | Computer Science & Engineering | IIT Roorkee -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.