A059942 A059941 translated from binary to decimal.
1, 1, 3, 2, 2, 3, 7, 4, 5, 4, 4, 5, 4, 7, 15, 8, 9, 8, 9, 10, 9, 8, 8, 9, 10, 9, 8, 9, 8, 15, 31, 16, 17, 16, 19, 16, 17, 16, 17, 18, 21, 16, 17, 18, 17, 16, 16, 17, 18, 17, 16, 21, 18, 17, 16, 17, 16, 19, 16, 17, 16, 31, 63, 32, 33, 32, 35, 32, 33, 32, 35, 36, 33, 32, 35, 32, 33, 32
Offset: 1
Examples
a(35)=19 since A059941(35)=10011.
Links
- Reinhard Zumkeller, Table of n, a(n) for n = 1..10000
Programs
-
Haskell
import Data.List (inits, tails) a059942 n = a059942_list !! (n-1) a059942_list = map (foldr (\d v -> v * 2 + 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
-
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, 2]); Table[a[n], {n, 1, 78}](* Jean-François Alcover, Nov 21 2011 *)
Formula
a(n) =A059943(n)/2
Extensions
Offset fixed by Reinhard Zumkeller, Apr 03 2014
Comments