OFFSET
1,3
LINKS
Reinhard Zumkeller, Table of n, a(n) for n = 1..10000
EXAMPLE
a(35)=10011 since the 35th number with 1's and 2's is 11211, the first digit and last digit are the same (1), the first two and the last two are the same (11), the first three and last three are not (112 and 211), the first four and last four are not (1121 and 1211) and the first five and last five are (11211).
MATHEMATICA
a[n_] := (id = Drop[ IntegerDigits[n+1, 2], 1] + 1; an = {}; Do[ PrependTo[an, If[Take[id, k] == Take[id, -k], 1, 0]], {k, 1, Length[id]}]; FromDigits[an]); Table[a[n], {n, 1, 42}](* Jean-François Alcover, Nov 21 2011 *)
PROG
(Haskell)
import Data.List (inits, tails)
a059941 n = a059941_list !! (n-1)
a059941_list = map (foldr (\d v -> v * 10 + d) 0) $ f a030341_tabf where
f (xs:xss)
| 0 `elem` xs = f xss
| otherwise = map fromEnum (zipWith (==)
(tail $ inits xs) (reverse $ init $ tails xs)) : f xss
-- Reinhard Zumkeller, Apr 03 2014
CROSSREFS
KEYWORD
base,nonn
AUTHOR
Henry Bottomley, Feb 14 2001
STATUS
approved