mukesh tiwari wrote:
Hello everyone. I am kind of new to python so pardon me if i sound
stupid.
I have to find out the last M digits of expression.One thing i can do
is (A**N)%M but my A and N are too large (10^100) and M is less than
10^5. The other approach was repeated squaring and taking
Yes, it can be done. Have a look at :
http://en.wikipedia.org/wiki/Modular_exponentiation
The algorithm is also mentioned in CLRS.I tried writing my own
modular-exponentiation code following CLRS but observed that python pow()
function is much more efficient.
Have a look at this problem :
a nice exercise to do can be this problem :
http://www.codechef.com/MARCH09/problems/A4/ , it deals with both cases,
first and last k digits and can be performed within O(log n)
On Sun, Feb 7, 2010 at 3:58 AM, Shashwat Anand anand.shash...@gmail.comwrote:
Yes, it can be done. Have a look at :
monkeys paw wrote:
div class=moz-text-flowed style=font-family: -moz-fixedmukesh
tiwari wrote:
Hello everyone. I am kind of new to python so pardon me if i sound
stupid.
I have to find out the last M digits of expression.One thing i can do
is (A**N)%M but my A and N are too large (10^100) and
On Feb 5, 8:14 pm, mukesh tiwari mukeshtiwari.ii...@gmail.com wrote:
I have to find out the last M digits of expression.One thing i can do
is (A**N)%M but my A and N are too large (10^100) and M is less than
10^5. The other approach was repeated squaring and taking mod of
expression. Is
Hello everyone. I am kind of new to python so pardon me if i sound
stupid.
I have to find out the last M digits of expression.One thing i can do
is (A**N)%M but my A and N are too large (10^100) and M is less than
10^5. The other approach was repeated squaring and taking mod of
expression. Is
On Feb 5, 8:14 pm, mukesh tiwari mukeshtiwari.ii...@gmail.com wrote:
Hello everyone. I am kind of new to python so pardon me if i sound
stupid.
I have to find out the last M digits of expression.One thing i can do
is (A**N)%M but my A and N are too large (10^100) and M is less than
10^5. The
On Fri, Feb 5, 2010 at 3:14 PM, mukesh tiwari
mukeshtiwari.ii...@gmail.com wrote:
Hello everyone. I am kind of new to python so pardon me if i sound
stupid.
I have to find out the last M digits of expression.One thing i can do
is (A**N)%M but my A and N are too large (10^100) and M is less
On Feb 5, 2:18 pm, Mark Dickinson dicki...@gmail.com wrote:
On Feb 5, 8:14 pm, mukesh tiwari mukeshtiwari.ii...@gmail.com wrote:
Hello everyone. I am kind of new to python so pardon me if i sound
stupid.
I have to find out the last M digits of expression.One thing i can do
is (A**N)%M