A215253 a(n) = decimal equivalent of A215254(n).
1, 2, 4, 9, 18, 37, 77, 150, 333, 601, 1202, 2405, 4941, 9622, 21325, 38489, 76978, 153957
Offset: 1
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.
a(4)=2 since 4 = 100, and 100 can be written as either 1.0.0 or 1.00. a(5)=2 from 1.0.1, 101. a(10)=3 from 1.0.1.0, 1.010, 101.1 Written as a triangle, the sequence is: 1, 1, 1, 2, 2, 2, 2, 4, 4, 3, 3, 3, 4, 3, 4, 8, 8, 5, 4, 5, 5, 5, 4, 6, 8, 5, 5, 6, 8, 6, 8, 16, 16, 9, 7, 9, 8, 6, 6, 10, 10, 6, 8, 8, 7, 7, 7, 12, 16, 9, 7, 10, 8, 8, 8, 11, 16, 10, 10, 11, 16, 12, 16, 32, ...
import Data.Map (Map, singleton, (!), insert) import Data.List (inits, tails) newtype Bin = Bin [Int] deriving (Eq, Show, Read) instance Ord Bin where Bin us <= Bin vs | length us == length vs = us <= vs | otherwise = length us <= length vs a215244 n = a215244_list !! n a215244_list = 1 : f [1] (singleton (Bin [0]) 1) where f bs m | last bs == 1 = y : f (succ bs) (insert (Bin bs) y m) | otherwise = f (succ bs) (insert (Bin bs) y m) where y = fromEnum (pal bs) + sum (zipWith (\us vs -> if pal us then m ! Bin vs else 0) (init $ drop 1 $ inits bs) (drop 1 $ tails bs)) pal ds = reverse ds == ds succ [] = [0]; succ (0:ds) = 1 : ds; succ (1:ds) = 0 : succ ds -- Reinhard Zumkeller, Dec 17 2012
isPal := proc(L) local d ; for d from 1 to nops(L)/2 do if op(d,L) <> op(-d,L) then return false; end if; end do: return true; end proc: A215244L := proc(L) local a,c; a := 0 ; if isPal(L) then a := 1; end if; for c from 1 to nops(L)-1 do if isPal( [op(1..c,L)] ) then a := a+procname([op(c+1..nops(L),L)]) ; end if; end do: return a; end proc: A215244 := proc(n) if n = 1 then 1; else convert(n,base,2) ; A215244L(%) ; end if; end proc: # R. J. Mathar, Aug 07 2012 # Caution: the last procedure applies A215244L to the reverse of the binary expansion of n, which is perfectly OK but might cause a problem if the procedure was used in a different problem. - N. J. A. Sloane, Aug 11 2012
palQ[L_] := SameQ[L, Reverse[L]]; b[L_] := b[L] = Module[{a = palQ[L] // Boole, c}, For[c = 1, c < Length[L], c++, If[palQ[L[[;;c]]], a = a + b[L[[c+1;;]]]]]; a]; a[n_] := If[n == 1, 1, b[IntegerDigits[n, 2]]]; a /@ Range[0, 106] (* Jean-François Alcover, Oct 27 2019 *)
A215244(k) = 4 for k = 7,8,12,14,18,22, so a(4) = 22.
The values of A215244(k) for k=8 through 15 are (4, 3, 3, 3, 4, 3, 4, 8), with minimal value a(3) = 3.
A215245 := proc(n) local a,k ; a := A215244(2^n) ; for k from 2^n+1 to 2^(n+1)-1 do a := min(a,A215244(k)) ; end do: a ; end proc: # R. J. Mathar, Aug 07 2012
palQ[L_] := SameQ[L, Reverse[L]]; b[L_] := b[L] = Module[{a = palQ[L] // Boole, c}, For[c = 1, c < Length[L], c++, If[palQ[L[[;; c]]], a = a + b[L[[c+1 ;;]]]]]; a]; a215244[n_] := If[n == 1, 1, b[IntegerDigits[n, 2]]]; a215245[n_] := Module[{a, k}, a = a215244[2^n]; For[k = 2^n+1, k <= 2^(n+1) - 1, k++, a = Min[a, a215244[k]]]; a]; a215245 /@ Range[0, 20] (* Jean-François Alcover, Oct 28 2019 *)
Comments