A082272 Smallest palindrome m such that n + m (m>0) is also a palindrome, or 0 if no such number exists.
1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 11, 99, 9, 8, 7, 6, 5, 4, 3, 2, 1, 11, 88, 9, 8, 7, 6, 5, 4, 3, 2, 1, 11, 77, 9, 8, 7, 6, 5, 4, 3, 2, 1, 11, 66, 9, 8, 7, 6, 5, 4, 3, 2, 1, 11, 55, 9, 8, 7, 6, 5, 4, 3, 2, 1, 11, 44, 9, 8, 7, 6, 5, 4, 3, 2, 1, 11, 33, 9, 8, 7, 6, 5, 4, 3, 2, 1, 11, 22, 9, 8, 7, 6, 5, 4, 3
Offset: 1
Examples
a(11) = 11, 11 + 11 = 22; a(12) = 99, 99 + 12 = 111; etc.
Programs
-
PARI
ispal(n) = eval(concat(Vecrev(Str(n)))) == n; nextpal(k) = k++; while(! ispal(k), k++); k; a(n) = {m = 1; while (! ispal(n+m), m = nextpal(m)); m;} \\ Michel Marcus, Jul 24 2014
Extensions
Edited by Patrick De Geest, Jun 08 2003
Comments