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.

A059941 Take the n-th number which is just a sequence of 1's and 2's (A007931): if the first k digits in order are the same as the last k digits in order then put 1 in the k-th from right digit of a(n), otherwise put a zero.

This page as a plain text file.
%I A059941 #15 Apr 03 2014 03:44:49
%S A059941 1,1,11,10,10,11,111,100,101,100,100,101,100,111,1111,1000,1001,1000,
%T A059941 1001,1010,1001,1000,1000,1001,1010,1001,1000,1001,1000,1111,11111,
%U A059941 10000,10001,10000,10011,10000,10001,10000,10001,10010,10101,10000
%N A059941 Take the n-th number which is just a sequence of 1's and 2's (A007931): if the first k digits in order are the same as the last k digits in order then put 1 in the k-th from right digit of a(n), otherwise put a zero.
%H A059941 Reinhard Zumkeller, <a href="/A059941/b059941.txt">Table of n, a(n) for n = 1..10000</a>
%e A059941 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).
%t A059941 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 *)
%o A059941 (Haskell)
%o A059941 import Data.List (inits, tails)
%o A059941 a059941 n = a059941_list !! (n-1)
%o A059941 a059941_list = map (foldr (\d v -> v * 10 + d) 0) $ f a030341_tabf where
%o A059941    f (xs:xss)
%o A059941      | 0 `elem` xs = f xss
%o A059941      | otherwise = map fromEnum (zipWith (==)
%o A059941                    (tail $ inits xs) (reverse $ init $ tails xs)) : f xss
%o A059941 -- _Reinhard Zumkeller_, Apr 03 2014
%Y A059941 A059942 is this sequence translated from binary to decimal. Cf. A007931, A059943.
%K A059941 base,nonn
%O A059941 1,3
%A A059941 _Henry Bottomley_, Feb 14 2001