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.

Showing 1-2 of 2 results.

A238845 Prefix overlap between binary expansions of n and n+1.

Original entry on oeis.org

0, 1, 1, 1, 2, 1, 2, 1, 3, 2, 3, 1, 3, 2, 3, 1, 4, 3, 4, 2, 4, 3, 4, 1, 4, 3, 4, 2, 4, 3, 4, 1, 5, 4, 5, 3, 5, 4, 5, 2, 5, 4, 5, 3, 5, 4, 5, 1, 5, 4, 5, 3, 5, 4, 5, 2, 5, 4, 5, 3, 5, 4, 5, 1, 6, 5, 6, 4, 6, 5, 6, 3, 6, 5, 6, 4, 6, 5, 6, 2, 6, 5, 6, 4, 6, 5, 6, 3, 6, 5, 6
Offset: 0

Views

Author

N. J. A. Sloane, Mar 22 2014

Keywords

Comments

The prefix overlap between two words is the length of their longest common prefix.

Examples

			8 = 1000 and 9 = 1001 have prefix overlap of 3, so a(8)=3.
		

Crossrefs

Programs

  • Haskell
    import Data.List (unfoldr); import Data.Tuple (swap)
    a238845 n = length $ takeWhile (== 0) $ zipWith (-) (bin n) (bin (n+1))
    where bin = reverse . unfoldr
    (\x -> if x == 0 then Nothing else Just $ swap $ divMod x 2)
    -- Reinhard Zumkeller, Mar 22 2014
    
  • Maple
    # prefix overlap between n and n+1 in base b:
    po:=proc(n,b) local t1,t2,l1,l2,c,L,i;
    t1:=convert(n,base,b); l1:=nops(t1);
    t2:=convert(n+1,base,b); l2:=nops(t2);
    c:=0; L:=min(l1,l2);
    for i from 1 to L do
    if t1[l1+1-i] = t2[l2+1-i] then c:=c+1; else break; fi; od:
    c;
    end;
    [seq(po(n,2),n=0..120)];
  • Mathematica
    a[n_] := With[{v = IntegerExponent[n+1, 2]}, Floor[Log[2, n+1]] - v + Boole[n+1 == 2^v] - Boole[n == 0]]; Table[a[n], {n, 0, 90}] (* Jean-François Alcover, Feb 03 2018, after Charles R Greathouse IV *)
    pol[n_]:=Module[{c1=IntegerDigits[n,2],c2=IntegerDigits[n+1,2]},Total[ Split[ If[#[[1]]==#[[2]],1,0]&/@Thread[{c1,Take[c2,Length[c1]]}]][[1]]]];Array[pol,100,0] (* Harvey P. Dale, Jun 12 2020 *)
  • PARI
    a(n)=my(v=valuation(n+1,2)); logint(n+1,2) - v + (n+1==1<Charles R Greathouse IV, Dec 29 2017

Formula

For all n > 0, a(n-1) = A000523(n) - A007814(n) + A209229(n) - A063524(n) = floor(log_2(n)) - v_2(n) + [exists(k,n==2^k)] - [n==1]. (see link) - Luc Rousseau, Dec 29 2017

A239092 Prefix overlap of dictionary consisting of decimal expansions of 0 through n.

Original entry on oeis.org

0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 81, 83, 85, 87, 89, 91, 93, 95, 97, 99, 100, 102, 104, 106, 108, 110
Offset: 1

Views

Author

N. J. A. Sloane, Mar 22 2014

Keywords

Comments

The prefix overlap between two words is the length of their longest common prefix.
The prefix overlap of a dictionary is the sum of the prefix overlaps between successive words.
Partial sums of A076489.
More than the usual number of terms are displayed in order to distinguish this from some closely related sequences.

Crossrefs

Different from A081600 and A028904.
Showing 1-2 of 2 results.