Generate the sequence number of bases in which
n is a palindrome (OEIS A126071).
Specifically, the sequence is defined as follows: given a number
n, express it in base
a = 1,2, ..., n, and count how many of those expressions are palindromic. "Palindromic" is understood in terms of reversing the base-
a digits of the expression as atomic units (thanks, @Martin Büttner). As an example, consider
a=1: the expression is
a=2: the expression is
a=3: the expression is
12: not palindromic
a=4: the expression is
a=5: the expression is
10: not palindromic
Therefore the result for
3. Note that OEIS uses bases
2, ..., n+1 instead of
1, ..., n (thanks, @beaker). It's equivalent, because the expressions in base
n+1 are always palindromic.
The first values of the sequence are
1, 1, 2, 2, 3, 2, 3, 3, 3, 4, 2, 3, 3, 3, 4, 4, 4, 4, 2, 4, 5, ...
Input is a positive integer
n. Output is the first
n terms of the sequence.
The program should theoretically work (given enough time and memory) for any
n up to limitations caused by your default data type in any internal computations.
All functions allowed. Lowest number of bytes wins.