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.

A077528 a(n) = smallest nontrivial (>1) palindrome == 1 (mod n).

Original entry on oeis.org

3, 4, 5, 6, 7, 8, 9, 55, 11, 111, 121, 66, 99, 121, 33, 171, 55, 77, 101, 22, 111, 323, 121, 101, 131, 55, 141, 88, 121, 373, 33, 232, 171, 141, 181, 1111, 77, 313, 121, 575, 505, 44, 353, 181, 323, 424, 1441, 99, 101, 868, 313, 10601, 55, 111, 393, 343, 929, 414
Offset: 2

Views

Author

Amarnath Murthy, Nov 08 2002

Keywords

Crossrefs

Cf. A002113.

Programs

  • Maple
    f:= proc(n) local d, S,j,q,x0,t,r,x;
        for d from 2 do
          S[ceil(d/2)+1]:= {0}:
          for j from ceil(d/2) to 1 by -1 do
            if j = (d+1)/2 then q:= 10^(j-1)
            else q:= 10^(j-1)+10^(d-j)
            fi;
            if j = 1 then x0:= 1 else x0:= 0 fi;
            S[j]:= {seq(seq(x*q+s mod n, x=x0..9), s=S[j+1])};
          od;
          if member(1, S[1]) then
             t:= 1; r:= 0;
             for j from 1 to ceil(d/2) do
               if j = (d+1)/2 then q:= 10^(j-1) else q:= 10^(j-1)+10^(d-j) fi;
               if j = 1 then x0:= 1 else x0:= 0 fi;
               for x from x0 to 9 do
                 if member(t - x*q mod n, S[j+1]) then
                    r:= r + x*q;
                    t:= t - x*q mod n;
                    break
                 fi
               od;
            od;
            return r
          fi
       od
    end proc:
    $3..9, seq(f(n),n=9..100); # Robert Israel, Dec 17 2019
  • Mathematica
    With[{pals=Select[Range[2,11000],PalindromeQ]},Table[SelectFirst[pals,Mod[#,n]==1&],{n,2,60}]] (* Harvey P. Dale, Dec 03 2023 *)

Extensions

Corrected and extended by Ray Chandler, Aug 20 2003