A343524 Palindromes with digits strictly increasing up to the middle digit.
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
Examples
121 and 1221 are legal terms but 122221 is not, since the digits 2,2 at positions 2 and 3 are not increasing.
Links
- Michael S. Branicky, Table of n, a(n) for n = 1..1023
Programs
-
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
Extensions
Terms < 100 prepended by Rémy Sigrist, Apr 25 2021
Comments