Skip to content

Commit d72bab9

Browse files
author
hasibulislam999
committed
Strictly Palindromic Number problem solved
1 parent 29f4efb commit d72bab9

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/**
2+
* Title: Strictly Palindromic Number
3+
* Description: An integer n is strictly palindromic if, for every base b between 2 and n - 2 (inclusive), the string representation of the integer n in base b is palindromic.
4+
* Author: Hasibul Islam
5+
* Date: 15/04/2023
6+
*/
7+
8+
/**
9+
* @param {number} n
10+
* @return {boolean}
11+
*/
12+
var isStrictlyPalindromic = function (n) {
13+
for (let i = 2; i <= n - 2; i++) {
14+
let val = n.toString(i);
15+
if (val !== val.split("").reverse().join("")) return false;
16+
}
17+
return true;
18+
};

0 commit comments

Comments
 (0)