- A combination of both
- A formula that you need to know:
(a * b) % k = (a % k)(b % k) % k.
- It means that
num % mod
do mod on every factor
multiply them all together
do mod again on the result
- Here we need to do some modifications toward
x % modfirst, so every factor in the following recursion calls is modded.
- As for the result, do another
Your task is to calculate
a is a positive integer and
b is an extremely
large positive integer given in the form of an array.
Input: a = 2147483647, b = [2,0,0]