Quantcast
Channel: CodeChef Discuss - latest questions
Viewing all articles
Browse latest Browse all 40121

python powers of 2

$
0
0
def power(m,n,x):
temp=power(m,n/2,x)
if n%2 == 0:
   return (temp%x*temp%x)%x
else:
   return (m*temp%x*temp%x)%x
t=int(input())
g=1298074214633706835075030044377087
while(t):
  t=t-1
  p=int(input()) 
  print (power(2,p+1,g)-1)%g

the code when compiled gives runtime error ..saying eof when reading a file.. plz.. tell me how to overcome this .. i'm new to python


Viewing all articles
Browse latest Browse all 40121

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>