0

How to compute N^N where N is very large 10^9 in python?

How to compute N^N where N is very large 10^9 in python? One condition is also given that answer should be given in ans*(%(10^9+7))

17th Jul 2018, 1:39 PM
Ayush Singhal
Ayush Singhal - avatar
12 Réponses
0
python supports arbitrarily large numbers (10^1000 and bigger) so you don't need to worry about it
17th Jul 2018, 1:56 PM
hinanawi
hinanawi - avatar
0
but I tried I used divide and conquer but nothing happens
17th Jul 2018, 2:00 PM
Ayush Singhal
Ayush Singhal - avatar
0
even I tried the built in function pow and also in this case nothing happens
17th Jul 2018, 2:01 PM
Ayush Singhal
Ayush Singhal - avatar
0
probably some other mistake that you made, because as you can see https://code.sololearn.com/czQQ3HKo802e/?ref=app
17th Jul 2018, 2:07 PM
hinanawi
hinanawi - avatar
0
but my question is for print(1000000000*1000000000) Time limit is exceeded
17th Jul 2018, 2:11 PM
Ayush Singhal
Ayush Singhal - avatar
0
10^9*10^9=10^18 which is way smaller than 10^1000, and it works for me, so this is some issue on your end
17th Jul 2018, 2:13 PM
hinanawi
hinanawi - avatar
0
sorry we have to compute 1000000000**1000000000
17th Jul 2018, 2:15 PM
Ayush Singhal
Ayush Singhal - avatar
0
Ayush Singhal that works on normal python compilers but not the SL one due to limitations
17th Jul 2018, 2:25 PM
hinanawi
hinanawi - avatar
0
This aslo doesn't work in my pc
17th Jul 2018, 2:31 PM
Ayush Singhal
Ayush Singhal - avatar
0
Ayush Singhal which error are you getting
17th Jul 2018, 3:01 PM
hinanawi
hinanawi - avatar
0
hinanawi have you tried this on pc
17th Jul 2018, 3:19 PM
Ayush Singhal
Ayush Singhal - avatar
0
Ayush Singhal what's the issue when you try it, i don't have access to a pc atm
17th Jul 2018, 3:25 PM
hinanawi
hinanawi - avatar