On Apr 18, 2007, at 11:52 AM, DanK wrote: > for i in range(1,((p-1)/2)+1): > e=i^(p-1-t)%p
Here is another example where modular arithmetic is important. The variable i could be as large as about p/2, and you are raising it to a power which is about as large as p. That means that i^(p-1-t) is going to be an absolutely humungous integer. Probably your computer is spending all its time just writing down this number. But you only want the result modulo p. So you should do the computation in Integers (p). It is extremely important to understand what is the difference between e.g. print 2^100000000 % 13 and R = Integers(13) x = R(2) print x^100000000 Once you understand exactly what is the difference between these computations, you will see how to make your program run much faster. If you can't see why the second method is so much faster than the first, I suggest you try to work out 2^100000000 % 13 **by hand**. Then you will truly understand :-) David --~--~---------~--~----~------------~-------~--~----~ To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sage-support URLs: http://sage.math.washington.edu/sage/ and http://sage.scipy.org/sage/ -~----------~----~----~----~------~----~------~--~---