We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
  • HackerRank Home

    HackerRank

  • |
  • Prepare
  • Certify
  • Compete
  • Hiring developers?
  1. Prepare
  2. Python
  3. Math
  4. Power - Mod Power

Power - Mod Power

Problem
Submissions
Leaderboard
Discussions
Editorial

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 shown below:

>>> pow(a,b) 

or

>>> a**b

It's also possible to calculate .

>>> pow(a,b,m)  

This is very helpful in computations where you have to print the resultant % mod.

Note: Here, and can be floats or negatives, but, if a third argument is present, cannot be negative.

Note: Python has a math module that has its own pow(). It takes two arguments and returns a float. It is uncommon to use math.pow().

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

Input Format
The first line contains , the second line contains , and the third line contains .

Constraints


Sample Input

3
4
5

Sample Output

81
1

Author

shashank21j

Difficulty

Easy

Max Score

10

Submitted By

176191

Need Help?


View discussions
View editorial
View top submissions

rate this challenge

MORE DETAILS

Download problem statement
Download sample test cases
Suggest Edits
  • Blog
  • Scoring
  • Environment
  • FAQ
  • About Us
  • Support
  • Careers
  • Terms Of Service
  • Privacy Policy