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.
%I A181935 #31 Apr 08 2025 05:32:51 %S A181935 1,1,1,2,2,1,1,3,3,1,2,2,2,1,1,4,4,1,1,2,2,2,1,3,3,1,2,2,2,1,1,5,5,1, %T A181935 1,2,2,2,1,3,3,1,3,2,2,2,1,4,4,1,1,2,2,2,2,3,3,1,2,2,2,1,1,6,6,1,1,2, %U A181935 2,2,1,3,3,2,2,2,2,1,1,4,4,1,2,2,2,3 %N A181935 Curling number of binary expansion of n. %C A181935 Given a string S, write it as S = XYY...Y = XY^k, where X may be empty, and k is as large as possible; then k is the curling number of S. %H A181935 Reinhard Zumkeller, <a href="/A181935/b181935.txt">Table of n, a(n) for n = 0..8191</a> %H A181935 Benjamin Chaffin, John P. Linderman, N. J. A. Sloane, and Allan R. Wilks, <a href="https://cs.uwaterloo.ca/journals/JIS/VOL16/Sloane/sloane3.html">On Curling Numbers of Integer Sequences</a>, Journal of Integer Sequences, Vol. 16 (2013), Article 13.4.3. %H A181935 <a href="/index/Bi#binary">Index entries for sequences related to binary expansion of n</a>. %F A181935 A212439(n) = 2*n + a(n) mod 2. - _Reinhard Zumkeller_, May 17 2012 %e A181935 731 = 1011011011 in binary, which we could write as XY^2 with X = 10110110 and Y = 1, or as XY^3 with X = 1 and Y = 011. The latter is better, giving k = 3, so a(713) = 3. %t A181935 f[n_, e_] := Module[{d = IntegerDigits[n, 2^e]}, Length[Split[d][[-1]]] - If[SameQ @@ d && Mod[n, 2^e] < 2^(e-1), 1, 0]]; a[n_] := Max[Table[f[n, e], {e, Range[Max[1, Floor[Log2[n]]]]}]]; a[0] = 1; Array[a, 100, 0] (* _Amiram Eldar_, Apr 08 2025 *) %o A181935 (Haskell) %o A181935 import Data.List (unfoldr, inits, tails, stripPrefix) %o A181935 import Data.Maybe (fromJust) %o A181935 a181935 0 = 1 %o A181935 a181935 n = curling $ unfoldr %o A181935 (\x -> if x == 0 then Nothing else Just $ swap $ divMod x 2) n where %o A181935 curling zs = maximum $ zipWith (\xs ys -> strip 1 xs ys) %o A181935 (tail $ inits zs) (tail $ tails zs) where %o A181935 strip i us vs | vs' == Nothing = i %o A181935 | otherwise = strip (i + 1) us $ fromJust vs' %o A181935 where vs' = stripPrefix us vs %o A181935 -- _Reinhard Zumkeller_, May 16 2012 %Y A181935 Cf. A212412 (parity), A212439, A212440, A212441, A007088, A090822, A224764/A224765 (fractional curling number). %K A181935 nonn,base %O A181935 0,4 %A A181935 _N. J. A. Sloane_, Apr 02 2012