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

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

A209554 Primes that expressed in none of the forms n<+>2 and n<+>3, where the operation <+> is defined in A206853.

Original entry on oeis.org

3, 97, 193, 257, 353, 449, 577, 641, 673, 769, 929, 1153, 1217, 1249, 1409, 1601, 1697, 1889, 2017, 2081, 2113, 2273, 2593, 2657, 2689, 2753, 3041, 3137, 3169, 3329, 3361, 3457, 3617, 4001, 4129, 4289, 4481, 4513, 4673, 4801, 4993, 5153, 5281, 5441, 5569
Offset: 1

Views

Author

Keywords

Comments

How relate these to A133870? - R. J. Mathar, Mar 13 2012
If the formulated below conjecture is true, then for n>=2, A209544 and this sequence coincide with A007519 and A133870 respectively.
Let n>=3 be odd and k>=2. We say that n possesses a property S_k, if for every integer m from interval [0,n) with the Hamming distance D(m,n) in [2,k], there exists an integer h from (m,n) with D(m,h)=D(m,n).
Conjecture (A209544 and this sequence correspond to cases k=2 and k=3 respectively).
Odd n>3 possesses the property S_k iff n has the form n=2^(2*k-1)*t+1.
Example. Let k=2, t=1. Then n=9=(1001)_2. All numbers m from [0,9) with D(m,9)=2 are 0,3,5.
For m=0, we can take h=3, since 3 from (0,9) and D(0,3)=2; for m=3, we can take h=5, since 5 from (3,9) and D(3,5)=2; for m=5, we can take h=6, since 6 from (5,9) and D(5,6)=2. - Vladimir Shevelev, Seqfan list Apr 05 2012.
For k=2 this conjecture is true (see comment in A182187). - Vladimir Shevelev, Apr 18 2012.

Crossrefs

Cf. A209544, A182187 (n<+>2), A182209 (n<+>3).
Cf. A133870.

Programs

  • Mathematica
    hammingDistance[a_,b_] := Count[IntegerDigits[BitXor[a,b],2],1]; vS[a_,b_] := NestWhile[#+1&,a,hammingDistance[a,#]=!=b&]; (* vS[a_,b_] is the least c>=a, such that the binary Hamming distance D (a,c)=b.vS[a,b] is Vladimir's a<+>b *) A209554 = Apply[Intersection, Table[Map[Prime[#]&, Complement[Range[Last[#]], #]&[Map[PrimePi[#]&, Union[Map[#[[2]]&, Cases[Map[{PrimeQ[#], #}&[vS[#,n]]&, Range[7500]], {True,_}]]]]]],{n, 2, 3}]] (* be careful with ranges near 2^x *)

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
Showing 1-3 of 3 results.