Strictly Palindromic Number
To determine whether a given number n
is strictly palindromic, we must check that its representation in each base from 2
to n  2
(inclusive) is palindromic. A number is palindromic if its representation reads the same forward and backward.
To convert a number to a given base, we can repeatedly divide the number by the base, recording the remainder at each step, and then reverse the list of remainders to obtain the number’s representation in that base.
Here’s the code to check if n
is strictly palindromic:


Here’s a breakdown of the code:
 The
convert_to_base
function converts a given number to the specified base and returns the result as a list of digits.  In the main function, we loop through each base from
2
ton  2
, convertingn
to that base and checking if the result is palindromic. If we find any nonpalindromic representation, we returnFalse
.  If no nonpalindromic representations are found, we return
True
.