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-4 of 4 results.

A206853 a(1)=1, for n>1, a(n) is the least number > a(n-1) such that the Hamming distance D(a(n-1), a(n)) = 2.

Original entry on oeis.org

1, 2, 4, 7, 11, 13, 14, 22, 26, 28, 31, 47, 55, 59, 61, 62, 94, 110, 118, 122, 124, 127, 191, 223, 239, 247, 251, 253, 254, 382, 446, 478, 494, 502, 506, 508, 511, 767, 895, 959, 991, 1007, 1015, 1019, 1021, 1022, 1534, 1790, 1918, 1982, 2014, 2030, 2038, 2042
Offset: 1

Views

Author

Vladimir Shevelev, Feb 13 2012

Keywords

Comments

For integers a, b, denote by a<+>b the least c>=a, such that D(a,c)=b (note that, generally speaking, a<+>b differs from b<+>a). Then a(n+1)=a(n)<+>2. Thus this sequence is a Hamming analog of odd numbers 1,3,5,...
A Hamming analog of nonnegative integers is A000225 and a Hamming analog of the triangular numbers is A000975.
All terms are odious (A000069).

Crossrefs

Cf. A182187 (n<+>2), A207063 (starting from 0).

Programs

  • Maple
    read("transforms");
    Hamming := proc(a,b)
            XORnos(a,b) ;
            wt(%) ;
    end proc:
    Dplus := proc(a,b)
            for c from a to 1000000 do
                    if Hamming(a,c)=b then
                            return c;
                    end if;
            end do:
            return -1 ;
    end proc:
    A206853 := proc(n)
            option remember;
            if n = 1 then
                    1;
            else
                    Dplus(procname(n-1),2) ;
            end if;
    end proc: # R. J. Mathar, Apr 05 2012
  • Mathematica
    myHammingDistance[n_, m_] := Module[{g = Max[m, n], h = Min[m, n]}, b1 = IntegerDigits[g, 2]; b2 = IntegerDigits[h, 2, Length[b1]]; HammingDistance[b1, b2]]; t = {1}; Do[If[myHammingDistance[t[[-1]], n] == 2, AppendTo[t, n]], {n, 2, 2042}]; t (* T. D. Noe, Mar 07 2012 *)
    t={x=1}; Do[i=x+1; While[Count[IntegerDigits[BitXor[x,i],2],1]!=2,i++]; AppendTo[t,x=i],{n,53}]; t (* Jayanta Basu, May 26 2013 *)
  • PARI
    next_A206853(n)={my(b=binary(n)); until(norml2(binary(n)-b)==2, n++>=2^#b & b=concat(0,b)); n}
    print1(n=1); for(i=1,99,print1(","n=next_A206853(n)))  \\ M. F. Hasler, Apr 07 2012

A182187 a(n) is the least m >= n such that the Hamming distance D(n,m) = 2.

Original entry on oeis.org

3, 2, 4, 5, 7, 6, 10, 11, 11, 10, 12, 13, 15, 14, 22, 23, 19, 18, 20, 21, 23, 22, 26, 27, 27, 26, 28, 29, 31, 30, 46, 47, 35, 34, 36, 37, 39, 38, 42, 43, 43, 42, 44, 45, 47, 46, 54, 55, 51, 50, 52, 53, 55, 54, 58, 59, 59, 58, 60, 61, 63, 62, 94, 95, 67, 66, 68
Offset: 0

Views

Author

Vladimir Shevelev, Apr 17 2012

Keywords

Comments

a(n) = n<+>2 (see comment in A206853).

Crossrefs

Cf. A206853 (trajectory of 1), A207063 (trajectory of 0).
Cf. A209544 (primes which are not terms), A209554 (and also not n<+>3).
Cf. A086799 ((n-1)<+>1), A182209 (n<+>3), A182336 (n<+>4).

Programs

  • Maple
    HD:= (i, j)-> add(h, h=Bits[Split](Bits[Xor](i, j))):
    a:= proc(n) local c;
          for c from n do if HD(n, c)=2 then return c fi od
        end:
    seq(a(n), n=0..100);  # Alois P. Heinz, Apr 17 2012
  • Mathematica
    t={}; Do[i=n+1; While[Count[IntegerDigits[BitXor[n,i],2],1]!=2,i++]; AppendTo[t,i],{n,0,66}]; t (* Jayanta Basu, May 26 2013 *)
  • PARI
    a(n) = bitxor(n, 3<>1+1,2)); \\ Kevin Ryde, Jul 09 2021
  • Python
    def a(n):
      m = n + 1
      while bin(n^m).count('1') != 2: m += 1
      return m
    print([a(n) for n in range(67)]) # Michael S. Branicky, Mar 02 2021
    
  • Sage
    def A182187(n):
        S = n.bits(); T = S; c = n; L = len(S)
        while true:
             H = sum(a != b for a, b in zip(S, T))
             if H == 2: return c
             c += 1; T = c.bits()
             if len(T) > L: L += 1; S.append(0)
    [A182187(n) for n in (0..66)]   # Peter Luschny, May 26 2013
    

Formula

If n is odd, then a(n) = n+2^(A007814(n+1)-1); if n == 2 (mod 4), then a(n) = n+2^(A007814(n+2)-1); if n == 0 (mod 4), then a(n) = n+3.
Using this formula, we can prove the conjecture formulated in comment in A209554 in the case k=2. Moreover, let us show that if N does not have the form 8*t or 8*t+1, then it can be represented in the form n<+>2. Indeed, in the cases N = 8*t+2, 8*t+4, 8*t+6, 8*t+3, 8*t+5 and 8*t+7 it is sufficient to choose n=N-4, n=N-2, n=N-1, n=N-3, n=N-2 and n = N-3 respectively; in the cases 8*t, 8*t+1, for every choice of n <= N, we do not obtain the equality n<+>2 = N.
In addition, note that n<+>1 = n + 2^A007814(n+1) = A086799(n+1).

Extensions

More terms from Alois P. Heinz, Apr 17 2012

A182336 a(n) is the least m>=n, such that the Hamming distance D(n,m)=4.

Original entry on oeis.org

15, 14, 13, 12, 11, 10, 9, 8, 19, 18, 17, 16, 17, 16, 16, 17, 31, 30, 29, 28, 27, 26, 25, 24, 33, 32, 32, 33, 32, 33, 34, 35, 47, 46, 45, 44, 43, 42, 41, 40, 51, 50, 49, 48, 49, 48, 48, 49, 63, 62, 61, 60, 59, 58, 57, 56, 64, 65, 66, 67, 68, 69, 70, 71, 79, 78, 77, 76, 75, 74
Offset: 0

Views

Author

Vladimir Shevelev, Apr 25 2012

Keywords

Comments

Or (see comment in A206853) a(n)=n<+>4.
Conjecture: for n > 96, n + 1 <= a(n) <= 9n/8 + 1. - Charles R Greathouse IV, Apr 25 2012

Crossrefs

Programs

  • PARI
    hamming(n)=my(v=binary(n));sum(i=1,#v,v[i])
    a(n)=my(k=n);while(hamming(bitxor(n,k++))!=4,);k \\ Charles R Greathouse IV, Apr 25 2012

Extensions

Terms corrected by Charles R Greathouse IV, Apr 25 2012

A346261 Lexicographically earliest sequence of decimal words starting with 10 such that each term has Hamming distance at least 2 from all earlier terms.

Original entry on oeis.org

10, 21, 32, 43, 54, 65, 76, 87, 98, 100, 111, 122, 133, 144, 155, 166, 177, 188, 199, 201, 212, 220, 234, 245, 253, 267, 278, 286, 302, 313, 324, 330, 341, 356, 368, 375, 389, 397, 403, 414, 425, 431, 440, 452, 469, 496, 504, 515, 523, 536, 542, 550, 561, 579, 605, 616, 627, 638, 649, 651
Offset: 1

Views

Author

Peter Woodward, Jul 11 2021

Keywords

Examples

			a(1) = 10 by definition.
a(2) = 21 because '2' has not yet appeared in the tens place and '1' has not yet appeared in the ones place.
		

Crossrefs

Lexicodes of minimal distance 1,2,3,... over alphabets of size 2: A001477, A001969, A075926, A075928, A075931, A075934, ...; size 3: A001477, A346002, A346003; size 10: A001477, A343444, A333568, A346000, A346001.
Cf. A207063.

Programs

  • Python
    def ham(m, n):
        s, t = str(min(m, n))[::-1], str(max(m, n))[::-1]
        return len(t) - len(s) + sum(s[i] != t[i] for i in range(len(s)))
    def aupton(terms):
        alst = [10]
        for n in range(2, terms+1):
            an = alst[-1] + 1
            while any(ham(an, aprev) < 2 for aprev in alst[::-1]):  an += 1
            alst.append(an)
        return alst
    print(aupton(60)) # Michael S. Branicky, Jul 22 2021

Extensions

Edited and corrected by N. J. A. Sloane, Jul 20 2021
Showing 1-4 of 4 results.