cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A050782 Smallest positive multiplier m such that m*n is palindromic (or zero if no such m exists).

Original entry on oeis.org

0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 21, 38, 18, 35, 17, 16, 14, 9, 0, 12, 1, 7, 29, 21, 19, 37, 9, 8, 0, 14, 66, 1, 8, 15, 7, 3, 13, 15, 0, 16, 6, 23, 1, 13, 9, 3, 44, 7, 0, 19, 13, 4, 518, 1, 11, 3, 4, 13, 0, 442, 7, 4, 33, 9, 1, 11, 4, 6, 0, 845, 88, 4, 3, 7, 287, 1, 11, 6, 0, 12345679, 8
Offset: 0

Views

Author

Patrick De Geest, Oct 15 1999

Keywords

Comments

Multiples of 81 require the largest multipliers.
From Jon E. Schoenfield, Jan 15 2015: (Start)
In general, a(n) is large when n is a multiple of 81. E.g., for n in [1..10000], of the 9000 terms where a(n)>0, 111 are at indices n that are multiples of 81; of the remaining 8889 terms,
755 are in [1..9],
1760 are in [10..99],
3439 are in [100..999],
2180 are in [1000..9999],
708 are in [10000..99999],
36 are in [100000..999999],
6 are in [1000000..9999999],
2 are in [10000000..99999999],
2 are in [100000000..999999999],
and 1 (the largest) is a(8891) = 8546948927,
but the smallest of the 111 terms whose indices are multiples of 81 is a(2997)=333667. (End)
a(n) = 0 iff 10 | n. a(n) = 1 iff n is a palindrome. If k | a(n) then a(k*n) = a(n)/k. - Robert Israel, Jan 15 2015

Examples

			E.g., a(81) -> 81 * 12345679 = 999999999 and a palindrome.
		

Crossrefs

Programs

  • Maple
    digrev:= proc(n) local L,d,i;
      L:= convert(n,base,10);
      d:= nops(L);
      add(L[i]*10^(d-i),i=1..d);
    end proc:
    f:= proc(n)
    local d,d2,x,t,y;
    if n mod 10 = 0 then return 0 fi;
    if n < 10 then return 1 fi;
    for d from 2 do
      if d::even then
        d2:= d/2;
        for x from 10^(d2-1) to 10^d2-1 do
           t:= x*10^d2 + digrev(x);
           if t mod n = 0 then return(t/n) fi;
        od
      else
        d2:= (d-1)/2;
        for x from 10^(d2-1) to 10^d2-1 do
          for y from 0 to 9 do
            t:= x*10^(d2+1)+y*10^d2+digrev(x);
            if t mod n = 0 then return(t/n) fi;
          od
        od
      fi
    od;
    end proc:
    seq(f(n),n=0 .. 100); # Robert Israel, Jan 15 2015
  • Mathematica
    t={0}; Do[i=1; If[IntegerQ[n/10],y=0,While[Reverse[x=IntegerDigits[i*n]]!=x,i++]; y=i]; AppendTo[t,y],{n,80}]; t (* Jayanta Basu, Jun 01 2013 *)
  • 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 # Chai Wah Wu, Dec 30 2014