1922. Count Good Numbers
On This Page
class Solution:
def countGoodNumbers(self, n: int) -> int:
mod = 10**9 + 7
def myPow(x, n):
res = 1
while n:
if (n & 1) == 1:
res = res * x % mod
x = x * x % mod
n >>= 1
return res
return myPow(5, (n + 1) >> 1) * myPow(4, n >> 1) % mod