Given a number n
, calculate the amount of bases in the range of [2, n)
in which b(n)
is a Palindrome.
Example
n = 8
has the base conversions:
2 = 1000
3 = 22
4 = 20
5 = 13
6 = 12
7 = 11
Of which 2 of them, 3 = 22
and 7 = 11
are palindromes. So return 2
.
Clarifications
- For the sake of convenience, Your answer only needs to be correct for inputs 3 - 36 inclusive, as few languages can handle base conversion of >36.
- A single digit number is considered a palindrome.
- This is sequence A135551 on OEIS
Test Cases
3 -> 1
4 -> 1
5 -> 2
6 -> 1
7 -> 2
8 -> 2
9 -> 2
10 -> 3
11 -> 1
12 -> 2
13 -> 2
14 -> 2
15 -> 3
16 -> 3
17 -> 3
18 -> 3
19 -> 1
20 -> 3
21 -> 4
22 -> 2
23 -> 2
24 -> 4
25 -> 2
26 -> 4
27 -> 3
28 -> 4
29 -> 2
30 -> 3
31 -> 3
32 -> 3
33 -> 3
34 -> 3
35 -> 2
36 -> 5
Finally
- Standard Loopholes Apply.
- This is code-golf, so fewest bytes wins.
- Have Fun!