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-6 of 6 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

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 *)

A207063 a(n) is the smallest number larger than a(n-1) with mutual Hamming distance 2 and a(1)=0.

Original entry on oeis.org

0, 3, 5, 6, 10, 12, 15, 23, 27, 29, 30, 46, 54, 58, 60, 63, 95, 111, 119, 123, 125, 126, 190, 222, 238, 246, 250, 252, 255, 383, 447, 479, 495, 503, 507, 509, 510, 766, 894, 958, 990, 1006, 1014, 1018, 1020, 1023, 1535, 1791, 1919, 1983, 2015, 2031, 2039, 2043
Offset: 1

Views

Author

Alois P. Heinz, Feb 14 2012

Keywords

Comments

The binary expansion of a(n) has an even number of 1's. So this is a subsequence of A001969. The odd analog is A206853.
This sequence has 4*k+1 = A016813(k) numbers with exactly 2*k 1's and no number with more than two 0's in their binary expansion.

Examples

			| n | a(n) | A007088(a(n))| A000120(a(n))|
+---+------+--------------+--------------+
| 1 |   0  |         0    |       0      |
| 2 |   3  |        11    |       2      |
| 3 |   5  |       101    |       2      |
| 4 |   6  |       110    |       2      |
| 5 |  10  |      1010    |       2      |
| 6 |  12  |      1100    |       2      |
| 7 |  15  |      1111    |       4      |
| 8 |  23  |     10111    |       4      |
		

Crossrefs

Cf. A182187 (next with Hamming distance 2), A206853 (iterate from 1).

Programs

  • Maple
    g:= proc(n) option remember; local l; l:= g(n-1);
          `if`(nops(l)=1, [l[1]+1, l[1]-1], `if`(nops(l)=2,
          `if`(l[2]<>0, [l[1], l[2]-1], [l[1]+1, 0, l[1]-1]),
          `if`(l[3]<>1, [l[1], l[2], l[3]-1], [l[1]])))
        end: g(1):= [2, 0, 1]:
    a:= n-> (l-> 2^l[1]-1 -add(2^l[i], i=2..nops(l)))(g(n)):
    seq(a(n), n=1..300);
  • Python
    def aupton(terms):
        alst = [0]
        for n in range(2, terms+1):
            an = alst[-1] + 1
            while bin(an^alst[-1]).count('1') != 2:  an += 1
            alst.append(an)
        return alst
    print(aupton(54)) # Michael S. Branicky, Jul 07 2021

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

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