OFFSET
0,13
COMMENTS
Every positive integer is a factor of a palindrome, unless it is a multiple of 10 (D. G. Radcliffe, see Links).
Every integer n has a multiple of the form 99...9900...00. To see that n has a multiple that's a palindrome (allowing 0's on the left) with even digits, let 9n divide 99...9900...00; then n divides 22...2200...00. - Dean Hickerson, Jun 29 2001
LINKS
Chai Wah Wu, Table of n, a(n) for n = 0..8180
P. De Geest, Smallest multipliers to make a number palindromic.
EXAMPLE
For n = 30 we have m = 3, 1*m = 3 is a palindrome, so a(30) = 1. For n = m = 12 the smallest palindromic multiple is 21*m = 252, so a(12) = 21.
MATHEMATICA
skp[n_]:=Module[{m=n/10^IntegerExponent[n, 10], k=1}, While[!PalindromeQ[k*m], k++]; k]; Array[ skp, 90, 0] (* Harvey P. Dale, Jul 04 2024 *)
PROG
(ARIBAS): stop := 20000000; for n := 0 to maxarg do k := 1; test := true; while test and k < stop do mp := omit_trailzeros(n)*k; if test := mp <> int_reverse(mp) then inc(k); end; end; if k < stop then write(k, " "); else write(-1, " "); end; end;
(Python)
from __future__ import division
def palgen(l, b=10): # generator of palindromes in base b of length <= 2*l
....if l > 0:
........yield 0
........for x in range(1, l+1):
............n = b**(x-1)
............n2 = n*b
............for y in range(n, n2):
................k, m = y//b, 0
................while k >= b:
....................k, r = divmod(k, b)
....................m = b*m + r
................yield y*n + b*m + k
............for y in range(n, n2):
................k, m = y, 0
................while k >= b:
....................k, r = divmod(k, b)
....................m = b*m + r
................yield y*n2 + b*m + k
def A050782(n, l=10):
....if n % 10:
........x = palgen(l)
........next(x) # replace with x.next() in Python 2.x
........for i in x:
............q, r = divmod(i, n)
............if not r:
................return q
........else:
............return 'search limit reached.'
....else:
........return 0
def A061906(n, l=10):
....return A050782(int(str(n).rstrip('0')), l) if n > 0 else 1
# Chai Wah Wu, Dec 30 2014
CROSSREFS
KEYWORD
base,easy,nonn
AUTHOR
Klaus Brockhaus, Jun 25 2001
STATUS
approved