MeetCode
Geometric Progression Term Mod
C
C++
Computer Mathematics
CSS
DSA
HTML
Java
JavaScript
NodeJS
PHP
Programming Interview
Python
ReactJS
SQL
Run
Submit
Dark
Problem Statement
Solutions
Submissions
Geometric Progression Term Mod
Medium
Computer Mathematics
Recurrences
23 views
Explanation
Complexity
Problem Statement
Given a,r,n,m compute a*r^(n-1) mod m.
Input Format
a r n m.
Output Format
One integer.
Example
Input
2 3 5 100
Output
62
Constraints
n up to 1e18
Input / Output Format
Input Format
a r n m.
Output Format
One integer.
Constraints
n up to 1e18
Examples
Input:
2 3 5 100
Output:
62
Example Solution (Public)
Computer Mathematics
Compute powMod(r,n-1,m) then multiply by a mod m.
Official Solution Code
Wrap
Copy
Compute powMod(r,n-1,m) then multiply by a mod m.
Please
login
to submit solutions.
Editor
C
C++
Computer Mathematics
CSS
DSA
HTML
Java
JavaScript
NodeJS
PHP
Programming Interview
Python
ReactJS
SQL
Test Cases
Output
Submission Result
Input
2 3 5 100
Expected Output
62
Compile Output
Error
Output
Please
login
to submit solutions.