HackerRank Power – Mod Power solution in python

In this Power – Mod Power problem we need to develop a python program that can read an integer input given at three lines and then we need to print the power and mode on the output screen.

HackerRank Power - Mod Power solution in python

Problem solution in Python 2 programming.

a = int(raw_input())
b = int(raw_input())
m = int(raw_input())
print pow(a,b)
print pow(a,b,m)

Problem solution in Python 3 programming.

# Enter your code here. Read input from STDIN. Print output to STDOUT
a,b,m = [int(input()) for _ in '123']
print(pow(a,b),pow(a,b,m),sep='n')

Problem solution in pypy programming.

# Enter your code here. Read input from STDIN. Print output to STDOUT
import math

a = input()
b = input()
m = input()
print pow(a,b)
print pow(a,b,m)

Problem solution in pypy3 programming.

# Enter your code here. Read input from STDIN. Print output to STDOUT
a=int(input())
b=int(input())
m=int(input())
print(int(pow(a,b)))
print(pow(a,b,m))