304 North Cardinal St.
Dorchester Center, MA 02124

# Power and Mod Power Hacker Rank Solution – Queslers

## Problem: Power and Mod Power Hacker Rank Solution

So far, we have only heard of Python’s powers. Now, we will witness them!
Powers or exponents in Python can be calculated using the built-in power function. Call the power function as a^b shown below:

`>>> pow(a,b) `

or

`>>> a**b`

It’s also possible to calculate a^b mod m

`>>> pow(a,b,m) `

This is very helpful in computations where you have to print the resultant % mod.
Note: Here, a and b can be floats or negatives, but, if a third argument is present, b cannot be negative.
Note: Python has a math module that has its own pow(). It takes two arguments and returns a float. Frankly speaking, we will never use math.pow().

You are given three integers: a, b, and m, respectively. Print two lines.
The first line should print the result of pow(a,b). The second line should print the result of pow(a,b,m).

#### Input Format :

The first line contains a, the second line contains b, and the third line contains m.

#### Constraints :

• 1 <= a <= 10
• 1 <= b <= 10
• 2 <= m <= 1000

#### Sample Input :

``````3
4
5
``````

#### Sample Output :

``````81
1
``````

### Power and Mod Power Hacker Rank Solution in python 2

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

### Power and Mod Power Hacker Rank Solution in python 3

``````# 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')``````

## Power and Mod Power Hacker Rank Solution in pypy

``````# 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)``````

## Power and Mod Power Hacker Rank Solution in pypy 3

``````# 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))``````
##### Power and Mod Power Hacker Rank Solution Review:

In our experience, we suggest you solve this Power and Mod Power Hacker Rank Solution and gain some new skills from Professionals completely free and we assure you will be worth it.

Power and Mod Power is available on Hacker Rank for Free, if you are stuck anywhere between compilation, just visit Queslers to get all Hacker Rank Solution

##### Conclusion:

I hope this Power and Mod Power Hacker Rank Solution would be useful for you to learn something new from this problem. If it helped you then don’t forget to bookmark our site for more Hacker Rank, Leetcode, Codechef, Codeforce Solution.

This Problem is intended for audiences of all experiences who are interested in learning about Data Science in a business context; there are no prerequisites.

Keep Learning!

More Hacker Rank Problem & Solutions >>

itertools.product() Hacker Rank Solution

String Validators Hacker Rank Solution

Text Alignment Hacker Rank solution

String validators Hacker Rank Solution