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.

A333770 Smallest palindromic number >= 3^n.

Original entry on oeis.org

1, 3, 9, 33, 88, 252, 737, 2222, 6666, 19691, 59095, 177771, 532235, 1594951, 4783874, 14355341, 43055034, 129141921, 387424783, 1162332611, 3486886843, 10460406401, 31381118313, 94143234149, 282429924282, 847288882748
Offset: 0

Views

Author

Eder Vanzei, Apr 04 2020

Keywords

Examples

			a(10) = 59095, because 3^10 = 59049 and 59095 is the smallest palindromic number >= 59049.
		

Crossrefs

Programs

  • Maple
    digrev:= proc(n) local L,i;
      L:= convert(n,base,10);
      add(L[-i]*10^(i-1),i=1..nops(L))
    end proc:
    f:= proc(n) local d,x,y,t;
      d:= ilog10(n)+1;
      if d::even then
        x:= floor(n/10^(d/2));
        t:= x*10^(d/2)+digrev(x);
        if t >= n then return t fi;
        (x+1)*10^(d/2)+digrev(x+1);
      else
        x:= floor(n/10^((d-1)/2));
        t:= x*10^((d-1)/2)+digrev(floor(x/10));
        if t >= n then return t fi;
        y:= x mod 10;
        if y < 9 then return t + 10^((d-1)/2) fi;
        x:= x+1;
        x*10^((d-1)/2)+digrev(floor(x/10));
      fi
    end proc:
    seq(f(3^i),i=0..30); # Robert Israel, May 04 2020
  • PARI
    a(n) = for(k=3^n, oo, if(Vecrev(v=digits(k))==v, return(k)));

Formula

a(n) = A262038(A000244(n)). - Michel Marcus, May 04 2020