Some numbers, such as \$14241\$, are palindromes in base 10: if you write the digits in reverse order, you get the same number.
Some numbers are the sum of 2 palindromes; for example, \$110=88+22\$, or \$2380=939+1441\$.
For other numbers, 2 palindromes are not enough; for example, 21 cannot be written as the sum of 2 palindromes, and the best you can do is 3: \$21=11+9+1\$.
Write a function or program which takes integer input n
and outputs the n
th number which cannot be decomposed as the sum of 2 palindromes. This corresponds to OEIS A035137.
Single digits (including 0) are palindromes.
Standard rules for sequences apply:
- input/output is flexible
- you may use 0- or 1- indexing
- you may output the
n
th term, or the firstn
terms, or an infinite sequence
(As a sidenote: all integers can be decomposed as the sum of at most 3 palindromes.)
Test cases (1-indexed):
1 -> 21
2 -> 32
10 -> 1031
16 -> 1061
40 -> 1103
This is code-golf, so the shortest answer wins.
n
, print n-th member of sequence OEIS An? Sounds promising... \$\endgroup\$