Skip to content

Commit f8a08d4

Browse files
authored
Create 1922-count-good-numbers.js
1 parent d332022 commit f8a08d4

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

1922-count-good-numbers.js

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/**
2+
* @param {number} n
3+
* @return {number}
4+
*/
5+
const countGoodNumbers = function (n) {
6+
n = BigInt(n)
7+
const MOD = BigInt(10 ** 9 + 7)
8+
let res =
9+
quick_pow(5n, (n + 1n) / 2n ) * quick_pow(4n, n / 2n)
10+
res %= MOD
11+
return res
12+
13+
function quick_pow(b, m) {
14+
let ans = 1n
15+
while (m) {
16+
if (m % 2n === 1n) ans = (ans * b) % MOD
17+
m = m / 2n
18+
b = (b * b) % MOD
19+
}
20+
return ans
21+
}
22+
}
23+

0 commit comments

Comments
 (0)