We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent e97508a commit 3324cfeCopy full SHA for 3324cfe
479-largest-palindrome-product.js
@@ -1,3 +1,25 @@
1
+/**
2
+ * @param {number} n
3
+ * @return {number}
4
+ */
5
+const largestPalindrome = function (n) {
6
+ if (n === 1) return 9
7
+ for (let i = 2, limit = 9 * 10 ** (n - 1); i < limit; i++) {
8
+ let left = 10 ** n - i
9
+ let right = +('' + left).split('').reverse().join('')
10
+ if (i ** 2 - 4 * right < 0) continue
11
+ const tmp = (i ** 2 - 4 * right) ** 0.5
12
+ if (tmp === Math.floor(tmp)) {
13
+ return (
14
+ (BigInt(right) + 10n ** BigInt(n) * (10n ** BigInt(n) - BigInt(i))) %
15
+ 1337n
16
+ )
17
+ }
18
19
+}
20
+
21
+// another
22
23
/**
24
* @param {number} n
25
* @return {number}
0 commit comments