i need to calculate ((2**a)*(a))%1000000007 where a is in order of 10^10. as much as i know python can handle int less than 2^1400. then is there any way to calculate this? or any mathematical rule to solve it?
            Asked
            
        
        
            Active
            
        
            Viewed 93 times
        
    0
            
            
        
        Pratik Narola
        
- 3
 - 1
 - 4
 
- 
                    1https://en.wikipedia.org/wiki/Modulo_operation#Equivalences – meowgoesthedog Jan 16 '19 at 15:45
 - 
                    See the two duplicates; one on the general approach to these problems (large numbers with a remainder), the other pointing to the `math.pow()` function, which *already* uses those same techniques to keep the results manageable. – Martijn Pieters Jan 16 '19 at 15:49
 
1 Answers
0
            This gets really easy since python's math.pow has an optional argument for modulo.
from math import pow
(pow(2, a, 1000000007)*a)%1000000007
This let's you not do the 2**a to all the digits and just return the modulo.
        Primusa
        
- 13,136
 - 3
 - 33
 - 53