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.

A261424 Difference between n and the largest palindrome <= n.

Original entry on oeis.org

0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
Offset: 0

Views

Author

N. J. A. Sloane, Aug 28 2015

Keywords

Comments

Up to a(301), this is the same as the sequence b(n) = least palindrome to be subtracted from n such that the difference is again a palindrome, or 10 if no such palindrome exists. But a(302) = 10 (= 302 - 292), while b(302) = 111 is the smallest palindrome P such that 302 - P is again a palindrome, 302 - 111 = 191. Similarly, b(403) = ... = b(908) = 111. For n = 1011, 1012, ..., 1110 one has a(n) = n - 1001 = 10, 11, 12, ..., 109 while b(n) = 22, 11, 44, 55, ..., 99, b(1019) = 121, b(1020) = 101, b(1021) = 22, 33, ..., 99, b(1029) = 131, 101, 10, 33, 44, ... and so on. - M. F. Hasler, Sep 08 2015
A further sequence which starts with the same values is c(n) = n-p, where p is the largest palindrome <= n such that n-p is the sum of m-1 palindromes, where m = A261675(n) is the minimal number of palindromes that add up to n. This means that c(n) = 0 (= a(n) = b(n)) if n is a palindrome; if n is the sum of 2 palindromes, then c(n) = b(n) is the smallest palindrome such that n - c(n) is again a palindrome; if n is the sum of three palindromes, then c(n) is the smallest possible sum of two palindromes such that n - c(n) is the largest possible palindrome. The numbers with A261675(n) = 3 are listed in A035137. Here, n = 1099 is the first index for which c(n) = 100 (= 99 + 1 and 1099 - 100 = 999) differs from a(n) = n - 1001 = 98 and from b(n) = 10. - M. F. Hasler, Sep 11 2015

Crossrefs

Programs

  • Maple
    # P has list of palindromes
    palfloor:=proc(n) global P; local i;
    for i from 1 to nops(P) do
       if P[i]=n then return(n); fi;
       if P[i]>n then return(P[i-1]); fi;
    od:
    end;
    [seq(n-palfloor(n),n=0..200)];
  • Mathematica
    palQ[n_] := Block[{d = IntegerDigits@ n}, d == Reverse@ d]; Table[k = n;
    While[Nand[palQ@ k, k > -1], k--]; n - k, {n, 0, 86}] (* Michael De Vlieger, Sep 09 2015 *)

Formula

a(n) = n - A261423(n). - M. F. Hasler, Sep 11 2015