login
A343524
Palindromes with digits strictly increasing up to the middle digit.
3
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 22, 33, 44, 55, 66, 77, 88, 99, 121, 131, 141, 151, 161, 171, 181, 191, 232, 242, 252, 262, 272, 282, 292, 343, 353, 363, 373, 383, 393, 454, 464, 474, 484, 494, 565, 575, 585, 595, 676, 686, 696, 787, 797, 898, 1221, 1331
OFFSET
1,3
COMMENTS
The maximum term in the sequence is 123456789987654321, if leading zeros are not allowed.
LINKS
EXAMPLE
121 and 1221 are legal terms but 122221 is not, since the digits 2,2 at positions 2 and 3 are not increasing.
PROG
(Perl)
#!/usr/bin/perl
open(OUT, ">incrDecrPalindrome.txt")||die "open fail OUT\n";
foreach $cand (0..100000){
@a=split("", $cand);
$b = join("", reverse @a);
next unless $cand==$b; # palindromes only
$n = int(@a/2.);
$n-- if &is_even(0+@a); # backoff if even count of digits
foreach $i (1..$n){
goto skip_num unless $a[$i-1] < $a[$i];
}
print OUT "$cand, ";
skip_num:;
print "";
}
print OUT "\n";
##########################################
sub is_even{ $_[0]/2. == int $_[0]/2. }
##########################################
(Python)
from itertools import combinations
A343524_list = [0]
for l in range(1, 4):
for d in combinations('123456789', l):
s = ''.join(d)
A343524_list.append(int(s+s[-2::-1]))
for d in combinations('123456789', l):
s = ''.join(d)
A343524_list.append(int(s+s[::-1])) # Chai Wah Wu, Apr 24 2021
CROSSREFS
Cf. A002113, A009993, A062351 (primes), A134941.
Sequence in context: A082810 A344550 A010785 * A032573 A190217 A222620
KEYWORD
nonn,base,fini,full
AUTHOR
James S. DeArmon, Apr 18 2021
EXTENSIONS
Terms < 100 prepended by Rémy Sigrist, Apr 25 2021
STATUS
approved