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-10 of 12 results. Next

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

A206960 a(0)=0, a(1)=1, for n>1, a(n) = n<*>n, where k<*>m = k<+>k<+>...<+>k is the m-1-fold iteration of the operation <+> defined in A206853.

Original entry on oeis.org

0, 1, 4, 9, 31, 66, 190, 385, 1022, 2055, 5112, 10242, 24572, 49153, 114686, 229377, 524287, 1048590, 2359281, 4718599, 10485753, 20971521, 46137342, 92274689, 201326590, 402653191, 872415224, 1744830466, 3758096380, 7516192769, 16106127358, 32212254721
Offset: 0

Views

Author

Vladimir Shevelev and Konstantin Shukhmin (shukhmin(AT)callsouth.net.nz), Feb 14 2012

Keywords

Comments

A Hamming's analog of n^2.

Crossrefs

Programs

  • Mathematica
    f[n_,k_]:=Module[{i=n+1},While[Count[IntegerDigits[BitXor[n,i],2],1]!=k,i++]; i]; Join[{0,1},Table[Nest[f[#,k]&,k,k-1],{k,2,18}]] (* Jayanta Basu, May 26 2013 *)

Formula

A010060(a(n)) = A010060(n). - Vladimir Shevelev and Alois P. Heinz, Feb 17 2012

Extensions

a(11)-a(31) from Alois P. Heinz, Feb 16 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

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

Original entry on oeis.org

7, 6, 5, 4, 9, 8, 8, 9, 15, 14, 13, 12, 16, 17, 18, 19, 23, 22, 21, 20, 25, 24, 24, 25, 31, 30, 29, 28, 36, 37, 38, 39, 39, 38, 37, 36, 41, 40, 40, 41, 47, 46, 45, 44, 48, 49, 50, 51, 55, 54, 53, 52, 57, 56, 56, 57, 63, 62, 61, 60, 76, 77, 78, 79, 71, 70, 69
Offset: 0

Views

Author

Vladimir Shevelev, Apr 18 2012

Keywords

Comments

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

Crossrefs

Cf. A086799 ((n-1)<+>1), A182187 (n<+>2), A182336 (n<+>4).
Cf. A209554 (primes which are not terms nor n<+>2 terms).

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)=3 then return c fi od
        end:
    seq(a(n), n=0..100);  # Alois P. Heinz, Apr 18 2012
  • PARI
    a(n) = bitxor(n, if(bitand(n,14)==4, 13, 7<>2+1,2))); \\ Kevin Ryde, Jul 10 2021
  • Python
    def d(n, m): return bin(n^m).count('1')
    def a(n):
        m = n+1
        while d(n, m) != 3: m += 1
        return m
    print([a(n) for n in range(67)]) # Michael S. Branicky, Jul 06 2021
    

Formula

If n==i mod 8, then a(n) = n-2*i+7, i=0,1,2,3; if n==4 mod 16, then a(n) = n+5; if n==12 mod 16, then a(n) = n+2^(A007814(n+4)-2); if n==5 mod 16, then a(n) = n+3; if n==13 mod 16, then a(n) = n+2^(A007814(n+3)-2); if n==6 mod 8, then a(n) = n+2^(A007814(n+2)-2); if n==7 mod 8, then a(n) = n+2^(A007814(n+1)-2).
Using this formula, we can prove conjecture formulated in comment in A209554 in case k=3. Moreover, one can prove that N could be represented in form n<+>2 or n<+>3 iff N is not a number of the forms 32*t, 32*t+1. - Vladimir Shevelev, Apr 25 2012

A207016 a(1) = 3 , for n > 1 a(n) is the least number greater than a(n-1) such that the Hamming distance D(a(n-1),a(n)) = 3.

Original entry on oeis.org

3, 4, 9, 14, 18, 21, 24, 31, 39, 41, 46, 50, 53, 56, 63, 79, 83, 84, 89, 94, 102, 104, 111, 115, 116, 121, 126, 158, 166, 168, 175, 179, 180, 185, 190, 206, 210, 213, 216, 223, 231, 233, 238, 242, 245, 248, 255, 319, 335, 339, 340, 345, 350, 358, 360, 367, 371
Offset: 1

Views

Author

Vladimir Shevelev, Feb 14 2012

Keywords

Comments

Odious and evil terms are alternating (cf. A000069, A001969).

Crossrefs

Programs

  • Mathematica
    a[1] = 3; a[n_] := a[n] = Module[{k = a[n - 1], m = a[n-1] + 1}, While[DigitCount[BitXor[k, m], 2, 1] != 3, m++]; m]; Array[a, 100] (* Amiram Eldar, Aug 06 2023 *)
  • PARI
    list(n)=my(v=vector(n));v[1]=3;for(i=2,n,v[i]=v[i-1]; while(hammingweight(bitxor(v[i-1],v[i]++))!=3,));v \\ Charles R Greathouse IV, Mar 26 2013

A208982 Numbers n such that the next larger number with mutual Hamming distance 1 is prime.

Original entry on oeis.org

1, 2, 3, 4, 5, 6, 9, 10, 12, 15, 16, 17, 18, 19, 21, 22, 23, 27, 28, 29, 30, 36, 39, 40, 41, 42, 43, 45, 46, 52, 57, 58, 60, 63, 65, 66, 67, 69, 70, 71, 72, 75, 77, 78, 81, 82, 88, 95, 96, 99, 100, 101, 102, 105, 106, 108, 111, 112, 119, 123, 125, 126, 129, 130, 136, 137, 138, 147, 148, 149, 150
Offset: 1

Views

Author

Vladimir Shevelev, Mar 04 2012

Keywords

Comments

If p is prime, then p-1 is in the sequence.
Using the prime number theorem in arithmetic progressions k*n+b with gcd(k,b)=1 and its uniformity over k<=exp(c*sqrt(log(x))), one can prove that the counting function of a(n)<=x is equivalent to 2*x/log(x), as x tends to infinity.

Crossrefs

Programs

  • PARI
    isok(n) = my(nextn = n+1); while (hammingweight(bitxor(n, nextn)) != 1, nextn++); isprime(nextn); \\ Michel Marcus, Jul 01 2014

A209544 Primes not expressed in form n<+>2, where operation <+> defined in A206853.

Original entry on oeis.org

3, 17, 41, 73, 89, 97, 113, 137, 193, 233, 241, 257, 281, 313, 337, 353, 401, 409, 433, 449, 457, 521, 569, 577, 593, 601, 617, 641, 673, 761, 769, 809, 857, 881, 929, 937, 953, 977, 1009, 1033, 1049, 1097, 1129, 1153, 1193, 1201, 1217, 1249, 1289, 1297, 1321
Offset: 1

Views

Author

Keywords

Comments

Trivially every odd prime is expressed in form n<+>1 (cf. A208982).
Are these related to A141174, A045390 or A007519? - R. J. Mathar, Mar 13 2012

Crossrefs

Formula

For n>=2, a(n) = A007519(n-1). - Vladimir Shevelev, Apr 18 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

A207460 Let a(1) = 4. For n > 1, a(n) is the least number greater than a(n-1) such that the Hamming distance D(a(n-1),a(n)) = 4.

Original entry on oeis.org

4, 11, 16, 31, 35, 44, 49, 62, 70, 73, 82, 93, 97, 110, 112, 127, 143, 145, 158, 162, 173, 176, 191, 199, 200, 211, 220, 224, 239, 241, 254, 286, 290, 301, 304, 319, 327, 328, 339, 348, 352, 367, 369, 382, 398, 400, 415, 419
Offset: 1

Views

Author

Vladimir Shevelev, Feb 18 2012

Keywords

Comments

All terms are odious (A000069).

Crossrefs

Programs

  • Mathematica
    nxt[n_]:=Module[{k=n+1},While[HammingDistance[PadLeft[IntegerDigits[ n,2],IntegerLength[ k,2]],IntegerDigits[k,2]]!=4,k++];k]; NestList[ nxt,4,50] (* Harvey P. Dale, Nov 07 2020 *)

A207472 Let a(1) = 5. For n > 1, a(n) is the least number greater than a(n-1) such that the Hamming distance D(a(n-1),a(n)) = 5.

Original entry on oeis.org

5, 26, 33, 62, 66, 93, 96, 127, 135, 152, 163, 188, 192, 223, 225, 254, 270, 273, 294, 313, 320, 351, 353, 382, 390, 409, 418, 445, 449, 478, 480, 511, 543, 545, 574, 578, 605, 608, 639, 647, 664, 675, 700, 704, 735, 737, 766, 782, 785, 806, 825, 832, 863, 865
Offset: 1

Views

Author

Vladimir Shevelev, Feb 18 2012

Keywords

Comments

Odious and evil terms are alternating (cf. A000069, A001969).

Crossrefs

Programs

  • Mathematica
    a[1] = 5; a[n_] := a[n] = Module[{k = a[n - 1], m = a[n-1] + 1}, While[DigitCount[BitXor[k, m], 2, 1] != 5, m++]; m]; Array[a, 100] (* Amiram Eldar, Aug 06 2023 *)
Showing 1-10 of 12 results. Next